Asp.Net MVC area parameter in config section

Do we need area parameter as manditory in routing configuration in asp.net mvc rounting? What if we do not give area as parameter at all?

With Area parameter: routes.MapRoute( name: "Test", url: "{Detailid}/details/{Id}", defaults: new { controller = "Default", action = "Index", area = string.Empty },

With out area parameter:
routes.MapRoute(
                name: "Test",
                url: "{Detailid}/details/{Id}",
                defaults: new { controller = "Default", action = "Index" },

If you want a URL route to be mapped to an area, then yes you must supply the area parameter. If you don't, then your app will try to map it to the default - which will cause it to think that your area name is a controller name.

For example, if you had an area called members and you wanted to go to the edit action method of the account controller, then the URL would presumably be /Members/Account/Edit. If you did not tell MVC that Members was an area, then it would look for a controller named 'Members' with action method 'Account' that takes a string parameter of 'Edit'

链接地址: http://www.djcxy.com/p/49992.html

上一篇: 这里发生了什么事? 什么样的成员是“可选”?

下一篇: 配置部分中的Asp.Net MVC区域参数