Last post Mar 01, 2012 12:48 PM by M1iS
Feb 24, 2012 05:34 PM|M1iS|LINK
I'm trying figure out what the best way would be to maintain a persistent URL parameter in a web application. Like the following code I've tried intercepting requests in global.asax on the BeginRequest event, append the parameter and rewriting the path
but the parameter is always stripped from the rewritten URL. How do I accomplish something like this?
protected void Application_BeginRequest(object sender, EventArgs e)
HttpContext.Current.RewritePath(HttpContext.Current.Request.Path + "?param1=value1");
Feb 27, 2012 01:43 AM|kwanann|LINK
what is the objective?
Feb 29, 2012 10:27 PM|rstrahl|LINK
RewriteUrl only rewrites the internal Url the server uses for processing - it's in effect faking the request to look different. But it has no effect on what displays in the browser's address bar.
There's no way to affect the way the browser displays the URL that was accessed from the server side. When you click on a link it has a URL and that URL is what shows in the browser's address bar. If you want to change the URL in the browser, the only way
to do that is to actually redirect the request to a new page.
The way to do this is either:
* redirect as mentioned
* write out URLs that are to be clicked properly with the query string parm already embedded
+++ Rick ---
Mar 01, 2012 12:48 PM|M1iS|LINK
Yes, thanks for pointing that out. I finally determined that when I stepped through the code and looked at an incoming request, I actually prefer that the parameter not show up in the browser's address bar.