How to modify request validation?

妖精的绣舞 提交于 2019-12-23 03:05:05

问题


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:

How to include quote characters as a route parameter? Getting "Illegal characters in path" message

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

<httpRuntime requestPathInvalidCharacters="&lt;,&gt;,*,%,:,&amp;,\" />

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?


回答1:


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".

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.



来源:https://stackoverflow.com/questions/4077336/how-to-modify-request-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!