Monday, March 26, 2012

Detect if a request is a partial postbak?

Hello,

is it possible to check if the current request is a partial postback or not?


I am getting PageRequestManagerParserErrorExceptions when i use a response filter that does a gzip compression in global.asax and my idea was to detect if the current request is a partial one. I that case i would not apply the filter.


The only question is if it is possible to detect the difference between normal and partial postbacks.

Any hints?

Ciao,

Ralf

ScriptManager.IsInAsyncPostBack.

Thanks!

My only problem is now that the process of applying the filter happens in global.asax and i have to find out how to access my scriptmanager instance (scriptmanager is contained in the masterpage) from within global.asax.


OK, i have added the scriptmanager to the application now so i cann access it from within global.asax but: When performing pagings in a gridview that is contained in an updatepanel the ScriptManager.IsAsyncPostback shows "false" (i have defined the paging events of the gridview as triggers so i expected to see IsAsyncPostback=true)

Is the IsAsyncPostBack property only valid at page level (i mean not useable in global.asax)?


I'm not sure, I'll defer to your experiences as an indicator that it's a page / instance level variable.

The request itself gets modified by the runtime, though, so that if you have an http reuqest fired by your updatepanel, it should have the additional http header of:

x-microsoftajax: Delta=true.

If you check the Request.Headers collection, that should be a way for your module to do the detection you're lookign for.

Hope that helps.

Paul


Hi Paul,

Yes, that helps! Now i can apply gzip/deflate filtersand use updatepanels without getting PageRequestManagerParserErrorExceptions by simply not using the filter on partial postbacks.

Thanks for the hint,

Ralf


No comments:

Post a Comment