如何处理“ +”在asp.net mvc3路由? [英] how to deal "+" in asp.net mvc3 routes?
问题描述
我的路线:
routes.MapRoute(
Tag,
tag / { t} / {action},
新的{controller = tag,action = unsolved}
);
链接如下:
< a href = / tag / @(Uri.EscapeDataString(tagName))/ unsolved> @ tagName< / a>
如果tagName不包含 +,则一切正常,否则,例如 http:// www.test.com/tag/c%2B%2B/unsolved\"(%2B来自@(Uri.EscapeDataString( +)),我收到错误消息:HTTP错误404.11-未找到
谁可以帮助我?谢谢!
您可以尝试在< web.config的code>< system.webServer> 部分,因为我怀疑您仅在IIS 7中而不是在Visual Studio开发服务器中才有此问题(顺便说一句)您应该在问题中提到过)
< system.webServer>
< validate validateIntegratedModeConfiguration = false />
<模块runAllManagedModulesForAllRequests = true />
< security>
< requestFiltering allowDoubleEscaping = true />
< / security> ;
< /system.webServer>
进一步阅读: http://www.hanselman.com/blog/ExperimentsInWackinessAllowingPercentsAnglebracketsAndOtherNaspythings> ASP $ URL my routes: the link like: if the tagName not contain "+",all work well , else ,like "http://www.test.com/tag/c%2B%2B/unsolved"(%2B come from @(Uri.EscapeDataString("+")),i get the error: HTTP error 404.11 - Not Found who can help me? thanks! You may try allowing double escaping in the Further reading: http://www.hanselman.com/blog/ExperimentsInWackinessAllowingPercentsAnglebracketsAndOtherNaughtyThingsInTheASPNETIISRequestURL.aspx 这篇关于如何处理“ +”在asp.net mvc3路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!routes.MapRoute(
"Tag",
"tag/{t}/{action}",
new { controller = "tag", action = "unsolved" }
);
<a href="/tag/@(Uri.EscapeDataString(tagName))/unsolved">@tagName</a>
<system.webServer>
section of your web.config as I suspect that you are having this problem only in IIS 7 and not in the Visual Studio development server (which by the way you should have mentioned in your question):<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
<security>
<requestFiltering allowDoubleEscaping="true"/>
</security>
</system.webServer>