Asp.net MVC processing "detects potentially dangerous request. Form values from the client ."

Source: Internet
Author: User

In this case, the server security settings prevent the client from sending HTML-containing data to the server. Previously, in Asp.net webform, The validaterequest attribute is set to false in the page command, or directly on the web. configure in the config file,

Now we use the Asp.net MVC framework to develop Web applications.ProgramOf course, it can also be configured in the web. config file, but in this case, the entire web application is basically restricted, sometimes only want to limit a part of the function. There are also two ways to do this in Asp.net MVC. First, add the [validateinput (false)] feature on the action to obtain client information. In addition, the current ASP. net mvc controller has an attribute validaterequest. Set this attribute to false to obtain the client value.

Method 1:

[Validateinput (false)]
Public actionresult demoview ()
{
//.........
Return view ();
}

In the second method, I directly set validaterequest to false in the Controller constructor. In fact, it can be set anywhere before obtaining data.

Public controllerdemocontroller ()
{
This. validaterequest = false;
}

 

Website development _ website production _ website maintenance _ online shop production _ online shop installation _ mall production _ mobile phone software _ enterprise website _ office software _ QQ: 471226865
Point more healthy

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.