.net-4.0 – 为什么有潜在危险的请求错误甚至ValidateRequest =
发布时间:2020-12-16 04:07:58 所属栏目:asp.Net 来源:网络整理
导读:这是我的Default.aspx %@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %html head runat="server" titlexss demonstration/title /head body form id="form1" runat="server" div W
这是我的Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" ValidateRequest="false" %> <html> <head runat="server"> <title>xss demonstration</title> </head> <body> <form id="form1" runat="server"> <div> We are looking for your feedback. <asp:TextBox ID="txtFeedback" runat="server" TextMode="MultiLine" /> <br /> <asp:Button ID="submit" runat="server" Text="Submit" onclick="submit_Click" /> <br /> Comment: <br /> <asp:Literal ID="ltlFeedback" runat="server" /> </div> </form> </body> </html> 以下是Default.aspx.cs public partial class _Default : System.Web.UI.Page { protected void submit_Click(object sender,EventArgs e) { this.ltlFeedback.Text = this.txtFeedback.Text; } } 当我运行应用程序并在文本框中输入以下内容时. <script>alert('Hello')</script> 我得到以下错误.
我的问题是为什么即使在页面中将ValidateRequest设置为false,我也会收到此错误? 解决方法
在.net framework 4.0中,您必须设置< httpRuntime requestValidationMode =“2.0”/> web.config中的标记.
<system.web> <compilation debug="false" targetFramework="4.0" /> <httpRuntime requestValidationMode="2.0"/> </system.web> 看看参考文章 – ASP.NET 4 Breaking Changes #1: requestValidationMode cause ValidateRequest=False to fail. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐
- 将MVC 2.0迁移到MVC 3.0 RC后使用Razor的问题
- asp.net-mvc – 升级到.Net 4.5和osFamily 3后无
- asp.net MVC的Html.RadioButton生成id和名称相同
- Asp.Net 5核心1.0不兼容/模板未找到
- 腾讯云-Linux-docker容器中安装vim 、telnet、if
- asp.net-mvc-4 – DataAnnotation Range属性的客
- asp.net – 此版本的SQL Server不支持用户实例登
- ASP.NET找到了具有相同ID“x”的多个控件.的Find
- asp.net-mvc – 将数据发布回ASP.NET MVC子操作
- C#_.net core 3.0自定义读取.csv文件数据_解决首
热点阅读