ASP.NET get viewstate in global.asax

Is it possible to get in viewstate in global.asax file? I am having a problem with viewstate for some clients, and I want to register what viewstate is in the Application_Error event.

+3
source share
1 answer

ViewState is sent to the server in a hidden input-field form with the name "__VIEWSTATE". Therefore, you can access the serialized ViewState using the following command:

Request.Form["__VIEWSTATE"]

But if you look at the source code of one of your pages (in your browser), you will see that ViewState is just a long encoded string:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
  value="/2RkRMb2dvLnBuZ2Ag0PD..." />

I am not sure if writing this line will help you find any errors.

0
source

Source: https://habr.com/ru/post/1716041/


All Articles