使用C#和VS 2010。
为了做一些最终的测试,我发现有些地方需要保护。使用一个简单的脚本来测试:
<script>alert('123');</script>
当然,页面会被弹出消息打断:
JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException:
An unknown error occurred while processing the request on the server.
The status code returned from the server was: 500
在页面指令中,它被设置为
ValidateRequest="false"
还使用设置为编码的文本框的AntiXSSLibrary:
string test = Encoder.HtmlEncode(txtSomeTextBox.Text);
上面的错误发生在一个有更新的页面上。
在没有更新的页面上进行测试时,错误是:
A potentially dangerous Request.Form value was detected from the client
(ctl00$ContentPlaceHolder1$txtTest="<script>alert('123')...").
页面上也有相同的代码。
正在输入的信息存储在Server中,稍后由同事查看。
为什么页码破了?
为什么HtmlEncode没有像预期的那样工作?
如有任何意见,我们将不胜感激。
发布于 2014-04-30 12:44:50
谢谢你的链接!
我到处找了好几个小时,没有运气。
尤其是在这里。
现在,我看到它需要对web.config文件进行简单的调整。
<httpRuntime requestValidationMode="2.0" />
谢谢!
https://stackoverflow.com/questions/23388236
复制相似问题