易截截图软件、单文件、免安装、纯绿色、仅160KB

关于ASP.Net的validateRequest=false(验证请求)

ASP.Net的validateRequest=false
      validateRequest="false"   指是否要IIS验证页面提交的非法字符,比如:>,<号等,当我们需要将一定格式得html代码获得,插入数据库时候,就要将这个属性设置为false,例如你将字体加粗等操作时。
   
ASP.Net 1.1后引入了对提交表单自动检查是否存在XSS(跨站脚本攻击)的能力。当用户试图用之类的输入影响页面返回结果的时候,ASP.Net的引擎会引发一个 HttpRequestValidationExceptioin。默认情况下会返回如下文字的页面:
以下是引用片段:
Server Error in '/YourApplicationPath' Application
A potentially dangerous Request.Form value was detected from the client
(txtName="<b>").
Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.
Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (txtName="<b>").
....
  这是ASP.Net提供的一个很重要的安全特性。因为很多程序员对安全没有概念,甚至都不知道XSS这种攻击的存在,知道主动去防护的就更少了。ASP.Net在这一点上做到默认安全。这样让对安全不是很了解的程序员依旧可以写出有一定安全防护能力的网站。
  但是,当我Google搜索 HttpRequestValidationException 或者 "A potentially dangerous Request.Form value was detected from the client"的时候,惊奇的发现大部分人给出的解决方案竟然是在ASP.Net页面描述中通过设置 validateRequest=false 来禁用这个特性,而不去关心那个程序员的网站是否真的不需要这个特性。看得我这叫一个胆战心惊。安全意识应该时时刻刻在每一个程序员的心里,不管你对安全的概念了解多少,一个主动的意识在脑子里,你的站点就会安全很多。
  为什么很多程序员想要禁止


相关文档:

asp.net 发送邮件

  几个月前,做用户注册模块要用到发送邮件功能,也碰到了些或大或小的问题,现在总结一下:
我先贴出发送邮件用到的代码:
public void SendEmail(string stremail, string content,string title)
{
MailMessage mm = new MailMessage();
mm.from = new MailAddress(公司邮箱) ......

Explained: Forms Authentication in ASP.NET 2.0

原地址:
http://msdn.microsoft.com/en-us/library/aa480476.aspx
IIS Authentication
ASP.NET authentication is a two-step process. First, Internet Information Services (IIS) authenticates the user and creates a Windows token to represent the user. IIS determines the authentication mode that it shoul ......

Asp.Net中gridview中嵌入的checkbox使用

<asp:checkbox id = "checkbox1" runat = "server" AutoPostBack = "true" OnCheckedChanged = "CheckAllBox_Checked" text = "全选">
<asp:CheckBox  ID = "CheckBox1" AutoPostBack = "true" OnCheckedChanged = "CheckBox1_Checked" runat = "server"/>
 protected void CheckBox1_Checked(obj ......

ASP.NET发送Email精简版

using System.Net;
using System.Net.Mail;
using System.Text;
    #region 发送Email
    public void sendEmail()
    {
        #region 验证email
        SmtpClient smtp = new SmtpCl ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号