views:

38

answers:

0

I'm trying to get a property (ImpersonatePersonId) from a page in global.asax but get a HttpException saying 'Request is not available in this context'.

I've been searching for some documentation on where in the pipeline the request is accessible, but as far as I can see all Microsoft can produce of documentation is one-liners like "PostRequestHandlerExecute: Occurs when the ASP.NET event handler finishes execution." which really doesn't give me much...

I've tried placing the call in both Pre and PostRequestHandlerExceute but with the same result.

I wonder if anyone with experience in this would be so kind as to tell me where the System.Web.UI.Page.Request object is available.

My code from global asax is below.

ICanImpersonate page = HttpContext.Current.Handler as ICanImpersonate;
ImpersonatedUser impersonatePerson = page != null ? page.ImpersonatePersonId : null;
Response.Filter = new TagRewriter(Response, new TagProcessor(Context, impersonatePerson).Process);

What I want to do is rewrite some HTML based on some request parameters.