c# - Asp.Net Viewstate exceeds max request length -
i'm stuck problem causes webapplication crash on regular bases. client (browser) http status code 500 after making (more 1) requests server. turned on iis failed request tracing , discoverd, request exceeded max request limit:
maximum request length exceeded
i looked @ hidden __viewstate
field , found, contains information expected , cryptic (probably base64 encoded) serialized object 49,500 characters. didn't know, why large , checked session , viewstate objectes in code behind. nothing suspicious.
since i'm displaying 2 asp.net charts , large data table (5k rows , aprox 20 cols) went web.config file , increased request limit to
</system.web> <httpruntime maxrequestlength="4194304"/> </system.web>
that kinda successfull, meaning server survived 1 more request bevore crashing outofmemoryexception
, claiming there no more memory available.
by now, i'm pretty sure there (and mean tons) unwanted, unneccesary, unused objects stored. (nice way of describing memory leak ;) ).
but @ point, lost. there way can viewstate before being serialized , check, kind of objects referenced there? can clear/delete/flush viewstate/session/whatever responsible in order have clean serialized viewstate not exceed default limit?
on server side : should code can take care of response time can follow these following things
1.try avoid viewstate : if don’t need viewstate disable view state on page level. there many levels of disabling of viewstate
control level : can disable viewstate specific control
<asp:textbox id="txtcustomerid" runat="server" enableviewstate="false" />
page level : can disable view state of whole page
<%@ page title="customer" language="c#" enableviewstate="false" %>
directory level : disable view state on directory level, add location tag under configuration tag in web.config, in following example disabling viewstate docs directory.
<location path="~/docs"> <system.web> <pages enableviewstate="false"></pages> </system.web> </location>
website level : disabling viewstate on website level, set enableviewstate property false of pages tag under system.web tag in web.config
<pages enableviewstate="false"></pages>
used : http://ianswerable.com/asp-net-performance-best-practice/
Comments
Post a Comment