Sunday, June 27, 2010

The Client Disconnected - Asp.net

You're likely to sporadically get this error message if you're in a web farm and you have a page where the user can make multiple selections, it typically happens in this scenario:
The user selects a drop downlist box that has an event on postback, but the user does this again before the request is sent back to the user, the user is now creating a second event that is being fired on the other webserver, the previous webserver tries to return the results of the old event to the user but the user is no longer there because the user is now on the other webserver.

The user will never see an error, but if your catching the errors and emailing/logging them you'll see them like shown below and be totally frustrated. Don't worry about it, just ignore it it's not even an problem, as long as you're trapping this kind of error nothing will go wrong. 

Type : System.Web.HttpException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Message : The client disconnected. Source : System.Web Help link : ErrorCode : -2147467259 Data : System.Collections.ListDictionaryInternal TargetSite : Void ThrowError(System.Exception, System.String, System.String, Boolean) Stack Trace : at System.Web.UI.ViewStateException.ThrowError(Exception inner, String persistedState, String errorPageMessage, Boolean macValidationError) at System.Web.UI.HiddenFieldPageStatePersister.Load() at System.Web.UI.Page.LoadPageStateFromPersistenceMedium() at System.Web.UI.Page.LoadAllState() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.src_rptprefs_chainhierarchy_aspx.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
            Inner Exception
            ---------------
            Type : System.Web.UI.ViewStateException, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
            Message : Invalid viewstate.
    Client IP: 10.21.4.8
    Port: 46784
    User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; InfoPath.1;

3 comments:

Brian said...

I am not an a web farm and get this exception every day, I have a hard coded machine key anyways and that still doesnt help,I like your advice but it is sound in a single server situation?

Anonymous said...

You would better go though this KB atricle of MS - instead of ignoring these errors you can ignore their reson - machine eys mismatch in servers farm.
http://support.microsoft.com/kb/312906/

Anonymous said...

You can elimnate the reson instead of ignoring it. The reason is machine key mismatch in servers frm (e. g. in azure deployment).

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...