What is wrong with my area routing in my bin deployed MVC4 app?

后端 未结 5 1886
我在风中等你
我在风中等你 2021-01-13 04:36

I have just deployed an MVC4 .NET 4.0 app to my web host, for \'live\' deployed testing. Non -area routes are working fine, e.g. my

@Html.ActionLink(\"Regis         


        
5条回答
  •  无人共我
    2021-01-13 05:08

    In your case because you specify area in query string, the routes from Global.asax.cs should apply. I belive you have something like this there:

        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Default",
                "{controller}/{action}/{id}",
                new { controller = "Home", action = "Index", id = UrlParameter.Optional }
            ).DataTokens.Add("area","Author");
        }
    

    This code makes Home/Index default route and skips Home/Index in url. If you change controller = "Home" on something else for example controller = "Home2" you will have displayed full link for Home/Index and new default route Home2/Index. Similar apply to default routes in areas if you have them specified.

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题