问题
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="<,>,*,%,:,&,\" />
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