我在这里有一个小问题。我需要在我正在工作的网站的每个网址的末尾添加一个尾部斜杠。我定义了网站内的所有链接,以具有如下所示的结尾斜杠:
<a href="/register/">Register</a>
虽然这工作正常,仍有一个小问题:它与生成的url来自调用RedirectToAction()。例如:
return RedirectToAction("Register","Users");
将导致url更改为/ register,没有尾部斜杠。我修改了我的路由系统如下:
routes.MapRoute("register","register/",new {controller = "Users",action = "Register"} );
仍然需要尾部斜线不会自动添加!
我查了这个question和这个question,但是这些是完全不同的,因为我不使用任何url重写库,我只是使用asp.net mvc路由系统。
那么你说什么家伙?
解决方法
RouteCollection类现在有一个AppendTrailingSlash布尔值,您可以将此行为设置为true。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。