【发布时间】:2018-08-01 08:05:53
【问题描述】:
我们正在尝试处理查询字符串中的“*”(星号)以进行搜索操作,并得到以下错误。我们尝试在 webconfig 中使用 requeststPathInvalidCacters 并在 Routes 中使用 [FromUri],但没有成功。 调用甚至没有到达控制器块
sample request Url: http://localhost:8080/test/search/ABCD*12*234
<httpRuntime targetFramework="4.5.2" maxRequestLength="2097152" requestPathInvalidCharacters="<,>,%,&,:,\,?,*" />
Exception:
<!DOCTYPE html>
<html>
<head>
<title>A potentially dangerous Request.Path value was detected from the client (*).</title>
<meta name="viewport" content="width=device-width" />
<body bgcolor="white">
<span><H1>Server Error in '/' Application.<hr width=100% size=1 color=silver></H1>
<h2> <i>A potentially dangerous Request.Path value was detected from the client (*).</i> </h2></span>
<font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
<b> Description: </b>An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
<br><br>
<b> Exception Details: </b>System.Web.HttpException: A potentially dangerous Request.Path value was detected from the client (*).<br><br>
<b>Source Error:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code>
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.</code>
</td>
</tr>
</table>
<br>
<b>Stack Trace:</b> <br><br>
<table width=100% bgcolor="#ffffcc">
<tr>
<td>
<code><pre>
[HttpException (0x80004005): A potentially dangerous Request.Path value was detected from the client (*).]
System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9859608
System.Web.PipelineStepManager.ValidateHelper(HttpContext context) +53
</pre></code>
【问题讨论】:
-
我确实尝试了该链接中提供的选项,但对我不起作用
标签: c# asp.net-web-api routing special-characters query-string