开发者

ASP NET MVC Route - Not Found

I'm having proble开发者_StackOverflow社区ms when using this route:

routes.MapRoute("ProductIndex", "pr-{key}", new { controller = "Home", action = "Product" });

When the key contains 'pr-', the route doesn't work.

Example: http://.../pr-my-product-key-with-pr-key


Routes don't work the way you want them to work, but it's easily converted

change your route to:

routes.MapRoute(
     "ProductIndex", 
     "pr/{key}", 
      new { controller = "Home", action = "Product" });

and use:

http://.../pr/my-product-key-with-pr-key

or, if you really want to use that "way" you need to override the Initialization method of your main controller are check the link with StartWith() and redirect to the proper Controller.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜