如何修改请求验证? [英] How to modify request validation?

查看:155
本文介绍了如何修改请求验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要请求提交到我的应用程序的URL,其​​中包含引用的字符串,如

I need to submit requests to my application as part of the URL, which contain quoted strings, such as

/search/"my query"

这是抛出一个错误,因为在以下问题概述:

this is throwing an error, as outlined in the following question:

<一个href=\"http://stackoverflow.com/questions/3968194/how-to-include-quote-characters-as-a-route-parameter-getting-illegal-characters\">http://stackoverflow.com/questions/3968194/how-to-include-quote-characters-as-a-route-parameter-getting-illegal-characters

我想实现由Scott Hanselman的建议,以改变

I'd like to implement the suggestion by Scott Hanselman to alter the

&LT;的httpRuntime requestPathInvalidCharacters =&放大器; LT;,&放大器; GT;,*,%,:,&放大器;放大器;,\\/&GT;

值不包括引号字符。但是,这并不似乎是在.NET 3.5 avaialable。

value to not include the quote character. But this doesn't appear to be avaialable in .net 3.5.

有人能指出如何得到这个工作?

Could somebody point out how to get this to work?

推荐答案

根据 HTTP: //forums.asp.net/t/1335994.aspx/1 ,用引号(或22%)字符的路径无法通过地图的路径路由。幸运的是,报价都在查询字符串参数的支持。

According to http://forums.asp.net/t/1335994.aspx/1, paths with the Quote (" or %22) character cannot be routed via the map path. Fortunately, quotes ARE supported in querystring parameters.

例如,而不是使用路由路径导航 /搜索/我的查询,你可以到那里使用查询字符串路径 /搜索?查询=我的查询

For example, instead of navigating using the route path /search/"my query", you can get there using the querystring path /search?query="my query".

另外,如果你真的在保持地图的路径(也许对于SEO的原因)设置,您可以使用类似的 IIS URL重写扩展路由到它这条道路的查询字符串对应未经用户以往任何时候都更明智的。

Alternatively, if you are really set on keeping your map path (maybe for SEO reasons), you can use something like the IIS URL Rewrite extension to route that path to it's querystring counterpart without the user ever being the wiser.

这篇关于如何修改请求验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆