static url mapping and routing issue
I've defined routes mapping here:
c开发者_如何学运维ontext.MapRoute(
"AddPost",
"Admin/Post/Add/",
new { controller = "Post", action = "Add" },
new[] { "mBlog.Admin.Controllers " }
);
context.MapRoute(
"admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional },
new[] { "mBlog.Admin.Controllers" }
);
"Admin" is an area.
The issue is when I requesting ~/admin/post/add
, I got 404 error, cannot find the resource. But once I removed the first route mapping, I got the desired results.
I've tested with RouteDebugger
, and the results shows it matches the first route.
Didn't know what's wrong with the first route.
try changing Admin/Post/Add/
to Admin/Post/Add
精彩评论