Search code examples
c#asp.nettraceeventvalidation

Tracing invalid postback or callback argument


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.


Solution

  • 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]
            }
        }
    }