ASP.Net - get size of viewstate

By [)ia6l0 iii

Use the following snippet in a webpage.

protected override void SavePageStateToPersistenceMedium(object state)

            System.Web.UI.LosFormatter formatter           = new System.Web.UI.LosFormatter();
            System.IO.StringWriter writer               = new System.IO.StringWriter();
            formatter.Serialize(writer, state);
            int viewStateSize = writer.ToString().Length;

Related FAQs

Use the IsClientConnected property of the HttpResponse class to find if the client is still connected. This is useful , so that we can check before we start some resource intensive operations on the server.
By default, this ASP.Net worker process runs with the Network Service account. You can use the identity element in Web.config to change this behavior. The following line will run ASP.Net under the mentioned identity.
You can handle errors in ASP.Net Ajax web pages using some Javascript code.
Use the Trace attribute under System.Web section to turn on trace information. Set the value of pageOutput to true. This would add the trace information to the bottom of the Web page.
You can avoid recompiling the entire website if certain files are changed. These files include dll files in the Bin folder, Global.asax and App_Code folders.
The <%= expressions are evaluated during render, and the <%# expressions are evaluated during the DataBind
ASP.Net - get size of viewstate  (1030 Views)