KindEditor 的使用方法---从客户端检测到有潜在危险的Request.Form值的asp.net代码

在web  config 里做如下的修改

(1) 在page属性里添加如下的内容 validateRequest="false"  enableSessionState="true" enableViewState="false">
(2)在</page>后面添加如下代码
<httpRuntime requestValidationMode="2.0"/> <!-- 这也是新添加的-->

 <pages validateRequest="false"  enableSessionState="true" enableViewState="false">
      <!--pages的三个属性是为了消除有潜在危险的Request.Form值 -->
      <namespaces >
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages"/>
      </namespaces>
    </pages>
 
   <httpRuntime requestValidationMode="2.0"/> <!-- 这也是新添加的-->
  </system.web>

 

  在做过上述的修改之后,再次重新生成程序。

(3) 如果经过上述两步操作之后 还有错误 那就进行如下操作  在你的方法上添加 属性  [ValidateInput(false)]

[HttpPost]
        [ValidateInput(false)]
        public ActionResult Edit(Message message)
        {
            if (ModelState.IsValid)
            {
                db.Entry(message).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(message);
        }

英文注解:when submitting an http post containing the < character mvc blocks this and reports a potentially dangerous script.
This can be overcome in .net 3.5 by adding the controller directive [ValidateInput(false)]
This does not work in .net 4.0 so it is not possible to post the contents of a textarea containing the < character.

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值