views:

1417

answers:

3

Here's a wierd one. I'm reusing a code base that unfortunately, must not be updated. This code makes a call to HttpContext.Current.Request.QueryString. Ideally, I need to push a value into this collection with every request that is made. Is this possible - perhaps in an HTTP Module?

+2  A: 

Without using reflection, the simplest way to do it would be to use the RewritePath function on the current HttpContext object in order to modify the querystring.

Using an IHttpModule, it might look something like:

context.RewritePath(context.Request.Path, context.Request.PathInfo, newQueryStringHere!);

Hope this helps!

Espo
A: 

Ditto Espo's answer and I would like to add that usually in medium trust (specific to many shared hostings) you will not have access to reflection so ... RewritePath will remain your probably only choice.

Andrei Rinea
A: 

Good thinking guys - thanks very much!

the Zapper