ASP. net mvc 3 RC ValidateInput (false) page verification failure Solution

Source: Internet
Author: User

There is no doubt that this is a bug. Many users have encountered this problem when upgrading to rc. In the past, normal submission was reported as long as the html Tag was included "... A potentially dangerous request is detected from the client. form value. "This problem occurs even if page verification is disabled in web. config.

For the causes and solutions, see:

Changes to client input verification in ASP. net mvc 3

For other solutions, see:

Http://weblogs.asp.net/imranbaloch/archive/2010/11/14/mvc-3-rc-bug-and-quick-solution.aspx

I use the latter solution:

1. Add using System. Web. Helpers; reference to the background page.

2. Modify the httppost method of the request:

Before:

1 public ActionResult ActionA (FormCollection form1)
2 {
3 return View ();
4}
5 public ActionResult ActionB (int I, FormCollection form)
6 {
7 return View ();
8}
9 public ActionResult ActionC (int I, FormCollection formABC, string j, [Bind (Include = "Name, Address")] Student s)
10 {
11 return View ();
12}
13 public ActionResult ActionD (int I, string j, FormCollection f, string k, string t)
14 {
15 return View ();
16}
17 public ActionResult ActionE (FormCollection form123, string t, string t2)
18 {
19 return View (new Student {Age = 30, Name = "Akbar "});
20}

 

After:

1 public ActionResult ActionA ()
2 {
3 FormCollection form1 = new FormCollection (Request. Unvalidated (). Form );
4 return View ();
5}
6 public ActionResult ActionB (int I)
7 {
8 FormCollection form = new FormCollection (Request. Unvalidated (). Form );
9 return View ();
10}
11 public ActionResult ActionC (int I, string j, [Bind (Include = "Name, Address")] Student s)
12 {
13 FormCollection formABC = new FormCollection (Request. Unvalidated (). Form );
14 return View ();
15}
16 public ActionResult ActionD (int I, string j, string k, string t)
17 {
18 FormCollection f = new FormCollection (Request. Unvalidated (). Form );
19 return View ();
20}
21 public ActionResult ActionE (string t, string t2)
22 {
23 FormCollection form123 = new FormCollection (Request. Unvalidated (). Form );
24 return View (new Student {Age = 30, Name = "Akbar "});
25}

 

Solution! This bug should be removed from the official version.

I hope this article will help you!

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.