从客户端检测到有潜在危险的Request的值(*) [英] A potentially dangerous Request.Path value was detected from the client (*)
问题描述
我收到了相当自我解释的错误:
I am receiving the rather self explanatory error:
从客户端(*)中检测到有潜在危险的Request的值。
A potentially dangerous Request.Path value was detected from the client (*).
问题是,我的网址中包含*:
the issue is that my url contains a *:
http://stackoverflow.com/Search/test * / 0/1/10/1
http://stackoverflow.com/Search/test*/0/1/10/1
此URL是用来填充搜索页测试*为搜索词和URL的其余部分涉及到其它各种过滤器。
This url is used to populate a search page where 'test*' is the search term and the rest of the url relates to various other filters.
我的问题是,如果有一个简单的解决方案,让我对这些特殊字符添加为搜索条件?
My question is if there is a simple solution to allow me to add these special characters as search terms?
我都试过,包括在web.config以下,但它有如果显示错误消息没有影响。
I have tried including the following in the web.config but it has no effect on if the error message is displayed.
我应该手动编码/解码特殊字符?
Should I be manually encoding / decoding the special characters?
是否有这样做的最佳做法?我想尽量避免使用查询字符串,但我想这是一个选项。
Is there a best practice for doing this? I would like to try and avoid using a query string but i guess it is an option.
应用程序本身是使用路由产生上述好的URL一个C#asp.net web表单应用程序。
The application itself is a c# asp.net webforms application that uses routing to produce the nice URL above.
推荐答案
的 *
字符不会在URL路径允许的,但使用它没有问题在查询字符串:
The *
character is not allowed in the path of the URL, but there is no problem using it in the query string:
http://localhost:3286/Search/?q=test*
这不是一个编码的问题, *
字符在一个URL没有特殊的意义,所以如果URL连接code与否并不重要。 c。使用不同的方案它,你将需要连接$ C $,然后去code吧。
It's not an encoding issue, the *
character has no special meaning in an URL, so it doesn't matter if you URL encode it or not. You would need to encode it using a different scheme, and then decode it.
例如使用任意字符作为转义字符:
For example using an arbitrary character as escape character:
query = query.Replace("x", "xxx").Replace("y", "xxy").Replace("*", "xyy");
和解码:
query = query.Replace("xyy", "*").Replace("xxy", "y").Replace("xxx", "x");
这篇关于从客户端检测到有潜在危险的Request的值(*)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!