I am using ASP.NET MVC 3. I created an area called Administration
. There is no default view associated with it, so if I type in www.mywebsite.com/Administration then there is an error. How would I go and define a default view when the user types in the above mentioned URL? Would I need to go and create a Home controller?
I would like to have something like: www.mywebsite.com/Administration or www.mywebsite.com/Administration/Index
AdministrationAreaRegistration.cs
has the following:
public 开发者_运维问答override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Administration_default",
"Administration/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
);
}
Not sure if this is possible?
You are about not to define default view, but default action. The code above misses the type of controller, action of which you want to use as default:
Suppose you have AdministrationHome
controller.
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Administration_default",
"Administration/{controller}/{action}/{id}",
new { action = "Index", controller="AdministrationHome", id = UrlParameter.Optional }
);
}
Perhaps make a Controller/Views called Administration in the root (not in the Administration area).
Call the view index
.
精彩评论