Asp. NET detects unsafe Request.Form value solution Rollup

Source: Internet
Author: User
Tags config root directory

This article mainly introduces the asp.net detection of unsafe request.form value solution Rollup, very comprehensive, the need for friends can refer to the

When we use a rich text editor such as CKEditor in a Web site, most of us encounter such a warning

This is because ASP.net defaults on the validation of page submissions (not only the ASP.net mvc,webforms also enables validation of the content submitted on the page by default), the key to solving this problem is to turn off validation on pages with rich-text editors or with pages that submit HTML code. Can be roughly divided into the following three kinds of situations:

Web site based on Framework2.0 WebForm

This scenario is best solved by setting validaterequest= "false" directly in the page directive at the top of the required pages

Web site based on Framework4 WebForm

This situation is slightly more troublesome than the framework2.0, not only need to declare validaterequest= "false" at the top of the page, but also need to further modify in Web.config file, add or modify in Web.config

  

Asp. MVC Web site

The first step, modify the Web.config file, if it is for the file in a directory, you can create a new Web.config file (Web.config file has "nearest principle", duplicate the definition of attributes, to the page closest to the Web.config file definition) , and add under the node

(If most files need to be set to cancel verification, you can directly modify the Web.config file in the root directory of the Web site)

In the second step, you need to add the [ValidateInput (false)] property on the action method for the page you want to set to indicate cancellation.

In the third step, the last page displayed should use the Html.raw () method to output the content with HTML, because HTML is escaped by default

The above mentioned is the entire content of this article, I hope you can enjoy.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.