How do I turn off viewstate for good?

后端 未结 6 2123
眼角桃花
眼角桃花 2020-12-29 08:35

Coming from a PHP background I love using clean URLs to grab data from one service to another.

However, on some of my ASP.NET projects I get the horrible ViewState p

6条回答
  •  感情败类
    2020-12-29 08:57

    You can turn off viewstate for the whole site like this:

        
    
    

    That said, you shouldn't be getting it on the url. ViewState is a hidden field that is sent to the server with a postback (which normally uses post). It keeps the state of the controls when the page was rendered to the client, sending it with each postback. If it works for the application you could switch to use post instead (the problem form is surely using get), if not take a look at Jon's answer.

    Check this link for more information on how the viewstate fits into the asp.net life cycle: http://msdn.microsoft.com/en-us/library/ms972976.aspx.

提交回复
热议问题