ASP. NET post page and correct solution to Mac failure in view status verification

Source: Internet
Author: User
Today, I made a homepage login page, which uses request. Form to receive parameters.
Then we made a test page named test. aspx, Code As follows:
<Body>
<Form ID = "form1" runat = "server" method = "Post" Action = "default. aspx">
<Div>
<Input type = "text" runat = "server" id = "solution" value = "(local)"/>
<Input type = "text" runat = "server" id = "username" value = "Ricky"/>
<Input type = "text" runat = "server" id = "password" value = "111"/>
<Input type = "Submit" runat = "server"/>
</Div>
</Form>
</Body>
However, during the test, we found that the test page was always post to itself.
After removing the runat tag, you can post it to default. aspx, but the value cannot be obtained.
Later, I checked it in IE. Source code And the HTML is like this <Form ID = "form1" method = "Post" Action = "test. aspx" >
That is to say, the generated HTML is always post to its own
It's easy to understand the problem.
Modify the Code:
<Form ID = "form1" runat = "server" method = "Post" Onsubmit = "This. Action = 'default. aspx '" >
Everything is OK, post to default. aspx
Then an error is reported.
An error occurred while verifying the view status Mac. If this applicationProgramIt is carried by the Network farm or cluster. Make sure that the same validationkey and verification are specified in the <machinekey> configuration.Algorithm. Autogenerate cannot be used in a group
I searched the internet and said the cause of the problem was that Asp.net's runat = 'server' encrypted viewstat Mac. Basically there are two solutions:
1: Modify the @ page attribute of the current page and add enableeventvalidation = "false" viewstateencryptionmode = "never"
Or add <pages enableeventvalidation = "false" viewstateencryptionmode = "never"/> in Web. config.
2: Specify validationkey and Verification Algorithm in Web. config.
< Machinekey Validation =" 3DES "Validationkey =" 319b474b1d2b7a87c996b280108bb36506a95aedf9b51211 " Decryption="3DES"Decryptionkey =" 280347bb36319b474c996b506a95aedf9b51211b1d2b7a87 "/>
However, it is useless and the problem persists.
After checking the information and adding the actual test, we finally found the correct solution.
Modify the @ page attribute of the current page and add enableeventvalidation = "false" enableviewstatemac = "false"
Or add <pages enableeventvalidation = "false" enableviewstatemac = "false"/>

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.