开发者

Where is SkipRequestValidation Attribute in Asp.net MVC

I am trying to use SkipRequestValidation attribute on property of my model But 开发者_StackOverflow中文版that attribute is not exist in any assembly of default ASP.NET MVC 3 project.

Where is SkipRequestValidation attribute ?


No such attribute exists out of the box in ASP.NET MVC 3 RTM. You have the [AllowHtml] attribute that you could apply on your model properties.


If you want to allow users to post html to your application, you must use ValidateInput attribute on methods that control the html contained requests; for example:

public class Home: Controller{
    [HttpPost]
    [ValidateInput(false)]
    public ActionResult Create(MyModel model){
        // do something
    }
}

here one or more properties of model, contains html value; Regards


Thanks, this post was so helpful, and after replacing SkipRequestValidation with [AllowHtml] issue is fixed and working fine.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜