使用自定义的模型绑定器时,从客户端检测到ASP.NET MVC有潜在危险的Request.Form值 [英] ASP.NET MVC A potentially dangerous Request.Form value was detected from the client when using a custom modelbinder

查看:201
本文介绍了使用自定义的模型绑定器时,从客户端检测到ASP.NET MVC有潜在危险的Request.Form值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

获取错误的位置:

  ValueProviderResult值= bindingContext.ValueProvider.GetValue(ConfirmationMessage);

我如何允许选择只值?

  [ValidateInput(假)]
        公共对象BindModel(ControllerContext controllerContext,ModelBindingContext的BindingContext)
        {
    ValueProviderResult值= bindingContext.ValueProvider.GetValue(ConfirmationMessage);
    ValueProviderResult值2 = bindingContext.ValueProvider.GetValue(ConfirmationMessage2);
}


解决方案

尝试:

 的Htt prequestBase请求= controllerContext.HttpContext.Request;
字符串重新= request.Unvalidated.Form.Get(ConfirmationMessage)

Getting the error here:

ValueProviderResult value = bindingContext.ValueProvider.GetValue("ConfirmationMessage");

How do I allow on a selection of values only? ie

[ValidateInput(false)]
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
    ValueProviderResult value = bindingContext.ValueProvider.GetValue("ConfirmationMessage");
    ValueProviderResult value2 = bindingContext.ValueProvider.GetValue("ConfirmationMessage2");
}

解决方案

Try:

HttpRequestBase request = controllerContext.HttpContext.Request;
string re = request.Unvalidated.Form.Get("ConfirmationMessage")

这篇关于使用自定义的模型绑定器时,从客户端检测到ASP.NET MVC有潜在危险的Request.Form值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆