开发者

static url mapping and routing issue

开发者 https://www.devze.com 2023-03-24 06:31 出处:网络
I\'ve defined routes mapping here: c开发者_如何学运维ontext.MapRoute( \"AddPost\", \"Admin/Post/Add/\",

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号