MVC无视我后面的斜线

MVC无视我后面的斜线

本文介绍了为什么ASP.NET MVC无视我后面的斜线?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑下面的路线:

    routes.MapRoute(
        "Service", // Route name
        "service/", // URL with parameters
        new {controller = "CustomerService", action = "Index"} // Parameter defaults
        );

使用 Url.Action(服务,为CustomerService)产生的URL /服务而不是预期的 /服务/

Using Url.Action("Service", "CustomerService") produces an url of /service instead of the expected /service/

有没有办法得到这个工作,还是我不得不求助于我实现自己的路由从 RouteBase

Is there any way to get this to work, or do I have to resort to implementing my own routing deriving from RouteBase?

推荐答案

Legenden - 没有即时解决问题的办法。你可能已经跨越对这个问题,这是非常丰富的。 回复到这里,基本上说他不认为这是一个大问题,如果是,你可以利用新的IIS7重写模块来解决它。

Legenden - there is no immediate solution to the problem. You may have run across Jason Young's blog post about the issue, which is very informative. Scott Hanselmann posted a reply to it here, basically stating that he didn't think it was a big deal, and if it is, you can leverage the new IIS7 rewrite module to solve it.

虽然最终,你可能想看看这个被张贴在穆拉德的StackOverflow类似的问题的解决方案:http://stackoverflow.com/questions/154295/trailing-slash-on-an-asp-net-mvc-route

Ultimately though, you might want to look at a solution that was posted by murad on a similar question on StackOverflow: http://stackoverflow.com/questions/154295/trailing-slash-on-an-asp-net-mvc-route

这篇关于为什么ASP.NET MVC无视我后面的斜线?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 09:12