possibility to get 'original' URL as shown in address bar?

Jun 9, 2009 at 9:50 AM

Hi, first of all thumbs up once again on your effort and great project,

 

I have another the following question

 

In the address bar I enter a URL which is rewritten to some other value by the URL rewriter (which is its purpose ofcourse :). Is there a possiblity to access the "original" Absolute URI in the code somehow? 

For example:

Address in browser ="http://localhost:36000/foo/bar/5/nice.aspx", is rewritten to "http://localhost:36000/somepage.aspx?a=foo&b=bar&value=5"

The rewritten URI ("http://localhost:36000/somepage.aspx?a=foo&b=bar&value=5") is accessible through the Request.Url.AbsoluteUri property.

Is there a way to access the value of the "original" URI "http://localhost:36000/foo/bar/5/nice.aspx" through a variable somehow?

 

Thanks!

Gert-Jan

Coordinator
Jun 9, 2009 at 12:49 PM

Hi Gert-Jan,

I use the standard header called.

X-Rewrite-Url

you can either access this through

HttpContext.Current.Request.Headers["X-Rewrite-Url"]

or

HttpContext.Current.Items["X-Rewrite-Url"]

If you are using GoDaddy as your host or any other medium trust environment, you must use the second method.

Hope this helps,

Nick

Jun 9, 2009 at 3:31 PM

Hey Nick,

Thanks very much for the quick response, your solution works like a charm for GET requests.

Do you think it makes sense it doesn't work for POST requests? (if it would be possible to retrieve the "original" non-rewritten URL for POST requests I would still like to know, but for now my problem is solved as I can amend some of my code :)).

Regards,

Gert-Jan

Coordinator
Jun 9, 2009 at 5:44 PM

Should work the same for POST requests, if the POST is actually going through the rewriter.  If the post doesn't go through the rewriter, it won't be there.