”/”在完全绕过 ASP 路由的 URL 中
我在 MVC 项目中的路线之一提供已上传的文档。
出于 SEO 和用户友好性的目的,我希望将文档标题包含在 URL 中,路由将从传入 URL 中获取 ID,将其与文档进行匹配,然后重定向到 ID 后附加文件名的 URL。由于文档标题可以包含多种字符,包括用于分解参数的字符,因此文件名是一个包罗万象的参数。
这对于标题中的几乎所有字符都适用,包括保留字符,例如“/”,但是当标题包含组合“/”时,路由会中断。不仅是不匹配此路由,而且显然绕过了整个应用程序并返回 404,我尝试使用 Phil Haack 的 RouteDebugger,但这也给出了 404,而不是捕获请求。
我的 web.config 已关闭 requestvalidation,但我似乎无法找到让应用程序捕获请求的方法。
One of my routes in an MVC project serves documents that have been uploaded.
For SEO and user friendliness purposes I want the document title to be included in the URL, the route will take the ID from the incoming URL, match it with the document then redirect to a URL with the filename appended to the ID. As document titles can have a wide variety of characters in the title including ones that are used to break up parameters the filename is a catchall parameter.
This works fine for almost all characters in the title including reserved ones such as "/" but when the title include the combination "/ " routing breaks. Not just in terms of not match this route but apparently bypassing the entirety of the application and returning a 404, I tried to use Phil Haack's RouteDebugger but that was also giving a 404 rather than catching the request.
My web.config has requestvalidation turned off and I can't seem to find anyway to get the application to catch the request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议你过滤这些字符,否则你会很头疼。 这是一个您可能会觉得有趣。
I would recommend you filtering those character or you will have many headaches. Here's a function you might find interesting.