views:

156

answers:

2

In my unhandled exception logging I see this error sporadically through the day on a given page. I don't have any controls that I create programmatically on the page or databind any buttons onto the page.

In my logging I grab the current handler which is where I know the page from and the stacktrace however the stacktrace doesn't give anything meaningful since it just says it boils down to Page.ProcessPostData.

Is there a way that I can log more meaningful data? Like perhaps what it got posted and what it expected to be posted?

I can never reproduce this anywhere.

+1  A: 

A common cause of this problem is when a user does not wait for the entire page to render before performing an action that causes a postback. How big is this page? Are users getting impatient?

Another place I see it is with repeater/templated controls with postback controls inside -- like a button inside a repeater's item template -- that incorrectly databind after a postback instead of just once. However, that would consistently fail so seems less likely.

I'm not sure how to get more information from the exception... How are you catching it to begin with? I don't think the Page object itself is instantiated at all when this exception occurs, so you'd probably have to use a custom HttpModule. Can you put a try/catch around ProcessRequest? That should give you access to the Request object and the posted data.

Bryan
The page isn't that large 470K, or 78K for a primed cache (per YSlow). I'm logging the exception in the global.asax Application_Error which lets me pull information from HttpContext.Current.CurrentHandler and Server.GetLastError() which lets me see which page the error came from
Chris Marisic
+2  A: 

you can see all of the request's form parameters like this:

if (System.Web.HttpContext.Current != null && System.Web.HttpContext.Current.Request != null) {
    foreach (string key in System.Web.HttpContext.Current.Request.Form.Keys) {
        if (key.IndexOf("__VIEWSTATE") == -1) {
            //key:   key
            //value: System.Web.HttpContext.Current.Request.Form[key]
        }
    }
}
Gabriel McAdams