Reputation: 1851
I am working on asp.net mvc 3. I have three areas in my project like,
MyProject/Areas/Blogs
MyProject/Areas/Forums
MyProject/Areas/Groups
Among these three, blogs view is startup view. for that i have set the globla.ascx as
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Blog", action = "Blog", id = UrlParameter.Optional }
);
and in BlogAreaRegistration.cs,
context.MapRoute(
"Blogarea_Default",
"{controller}/{action}/{id}",
new { controller = "Blog", action = "Blog", id = UrlParameter.Optional }
);
and in ForumAreaRegistration.cs,
context.MapRoute(
null,
"Forums/{action}/{id}",
new {controller="Forums", action = "Forum", id = UrlParameter.Optional }
);
and in GroupsAreaRegisration.cs,
context.MapRoute(
"Groups_default",
"Groups/{controller}/{action}/{id}",
new { controller = "Groups", action = "Group", id = UrlParameter.Optional }
);
Here Forum and Blog are work as i desire but the Group does not work it always shows 404 Resource not found page so please guide me if i did any mistake in the process.
Upvotes: 0
Views: 100
Reputation: 10487
You should remove either Groups/
or {controller}/
from your GroupsAreaRegisration.cs
code block - then it should work. I'd remove {controller}/
, so the code will be:
context.MapRoute(
"Groups_default",
"Groups/{action}/{id}",
new { controller = "Groups", action = "Group", id = UrlParameter.Optional }
);
Also in BlogAreaRegistration.cs
I'd replace {controller}
with Blog
, as you might get quite unexpected results otherwise. The complete code here will be
context.MapRoute(
"Blogarea_Default",
"Blog/{action}/{id}",
new { controller = "Blog", action = "Blog", id = UrlParameter.Optional }
);
Upvotes: 0
Reputation: 7445
Try change
context.MapRoute(
"Groups_default",
"Groups/{controller}/{action}/{id}",
new { controller = "Groups", action = "Group", id = UrlParameter.Optional }
);
for:
context.MapRoute(
"Groups_default",
"Groups/{action}/{id}",
new { controller = "Groups", action = "Group", id = UrlParameter.Optional }
);
Upvotes: 2