Simple MVC 3.0 Routing Problem
I have an MVC 3.0 Routing problem. I have the following in a CheckListController class:
public ActionResult Index(int id)
{
//poop
return View("ChecklistControl");
}
Then, in the AreaRegistration.cs that houses that controller, i have the following:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"CommonControls_defaultWithId",
"CommonControls/{controller}/{action}/{id}",
new { action = "Index", id = 0 }
);
context.MapRoute(
"CommonControls_default",
"Co开发者_JAVA百科mmonControls/{controller}/{action}",
new { action = "Index" }
);
}
However, when i try to browse to it via http://localhost:2064/CommonControls/Checklist/1
i get a 404 error, even though i have that route registered.
any ideas?
The URL that matches that rout is http://localhost:2064/CommonControls/Checklist/Index/1
What I think you want is
context.MapRoute(
"CommonControls_defaultWithId",
"CommonControls/{controller}/{id}",
new { action = "Index", id = 0 }
);
The two Routes seems the same. Remove the latter one and try again.
精彩评论