The ASPX page does not output the nput type = hidden name = "_ viewstate" method.

Source: Internet
Author: User

Open the source file of the ASPX page. By default, there is a segment <input type = "hidden" name = "_ viewstate" id = "_ viewstate" value = "/wepdwuk">.

The more controls the server, the more characters the value contains.

Value stores the status and value of the control and uses base64 encoding.

 

The method that does not display viewstate.
1. Set enableviewstate = "false" in the pages configuration node of the web. config file, or set it in the header of each ASPX page.

2. Delete the runat = "server" attribute in

4. Override the loadpagestatefrompersistencemedium () and savepagestatetopersistencemedium (object state) methods in the page class.

Protected losformatter;

Protected override object loadpagestatefrompersistencemedium ()
{
String key = request. rawurl + "_ viewstate ";

If (session [Key]! = NULL)
{
Memorystream stream = (memorystream) session [Key];
Stream. Seek (0, seekorigin. Begin );
Return losformatter. deserialize (Stream );
}

Return NULL;
}

Protected override void savepagestatetopersistencemedium (object state)
{
String key = request. rawurl + "_ viewstate ";

Memorystream stream = new memorystream ();

Losformatter. serialize (stream, State );

Stream. Flush ();

Session [Key] = stream;
}

 

5. Set <Form ID = "form1" runat = "server" enableviewstate = "false">.

This setting will still exist on the page. <input type = "hidden" name = "_ viewstate" id = "_ viewstate" value = "/wepdwuk">,

However, the value contains fewer characters.

 

The above content is post

For more information, see

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.