IIS友好的URL

时间:2015-05-13 11:08:05

标签: iis

我有一个非常大的问题,我在几天前试过seo友好的网址,它会在本地工作,但当我把我的项目放在iis上时显示:

  

404错误

我的路线是:

 routes.MapRoute(
                   "Slug", // Route name
                   "{slug}/{cat}/{langx},{longi}", // URL with parameters
                   new { controller = "Demo", action = "Index"} // Parameter 

defaults
           );

我的重定向方法是:

window.location.href=""+add+"/"+category+"/"+lang+","+longit+"";

在执行方法之前的我的ActionFilterAttribute:

public class SlugToIdAttribute : ActionFilterAttribute
    { 
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {               
            var slug = filterContext.RouteData.Values["slug"] as string;
            var cat = filterContext.RouteData.Values["cat"] as string;
            var latitude = filterContext.RouteData.Values["langx"] as string;
            var longitute = filterContext.RouteData.Values["longi"] as string;
            var category = "";
            switch (cat)
            {
                case "Resturant":
                    category = "1";
                    break;
                case "Health and Beauty":
                     category = "2";
                    break;
                case "Travel":
                    category = "3";
                    break;
                case "Free Deal":
                     category = "4";
                    break;
                case "Activity and hobbies":
                     category = "5";
                    break;
                case "Miscellaneous":
                     category = "6";
                    break;
                case "Grocery":
                     category = "7";
                    break;
                default:
                     category="1";
                    break;

            }


                string strg=slug.Replace("-",",");
                if (latitude != null)
                {
                    string lat = latitude.Replace("-", ".");
                    if (longitute != null)
                    {
                        string log = longitute.Replace("-", ".");
                        //SlugIds.TryGetValue(slug, out id);

                        filterContext.ActionParameters["ULat1"] = lat;
                        filterContext.ActionParameters["ULong1"] = log;
                    }
                }
                filterContext.ActionParameters["address1"] = slug;
                filterContext.ActionParameters["UMainCat1"] = category;

            base.OnActionExecuting(filterContext);
        }
    }

请帮忙。

0 个答案:

没有答案