Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating/Intercepting HttpContext.Current.Request.QueryString

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?

like image 305
the Zapper Avatar asked Apr 24 '26 08:04

the Zapper


1 Answers

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!

like image 70
Espo Avatar answered Apr 28 '26 19:04

Espo