使用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
在page指令中,设置
ValidateRequest="false"
还使用AntiXSSLibrary,文本框设置为编码:
string test = Encoder.HtmlEncode(txtSomeTextBox.Text);
在包含更新面板的页面上发生上述错误
并且在没有updatepanel的页面上进行测试,错误是:
A potentially dangerous Request.Form value was detected from the client
(ctl00$ContentPlaceHolder1$txtTest="<script>alert('123')...").
在该页面上也有相同的代码。
输入的信息存储在SQL Server中,稍后由同事查看。
为什么页面破了?
为什么HtmlEncode没有按预期工作?
任何意见都表示赞赏。
答案 0 :(得分:0)
感谢您的链接!
我到处搜寻了好几个小时,没有运气
特别是在这里
现在我看到它需要对web.config文件进行简单的调整。
<httpRuntime requestValidationMode="2.0" />
感谢!!!!!