How to specify default Area without adding area = “” to every ActionLink

前端 未结 2 1322
余生分开走
余生分开走 2021-02-13 10:27

I have a large existing application built on ASP.NET MVC2 RC2.

All of my links look like this: htp//site/controller/action/id

I just added an Area called:

2条回答
  •  眼角桃花
    2021-02-13 11:15

    You can do one of two things. You can either move/copy your controllers/actions into the proper area or write some new controllers for the new area (which is the approach I recommend), or you can write a custom route that forces the new area to the root (which I don't recommend, as it defeats the whole purpose of having areas):

    routes.MapRoute(
        "BigBird_Override",                                             
        "BigBird/{controller}/{action}/{id}",                          
        new { area = String.Empty }
    );
    

提交回复
热议问题