Alex Rivera | Logout

How to get original url after HttpContext.RewritePath() has been called

Asked 2010-03-11T18:22:59.240
16

I am working on a web app which makes use of a 3rd party HttpModule that performs url rewriting.

I want to know if there's any way to determine the original url later on in Application_BeginRequest event. For example...

Original url:
http://domain.com/products/cool-hat.aspx

Re-written url (from 3rd party httpmodule):
http://domain.com/products.aspx?productId=123

In the past I have written HttpModules that store the original url in HttpContext.Items but, this is a 3rd party app and I have no way of doing that.

Any ideas would be appreciated.

Edit
Report

1 Answer

10

I had the same problem, but I wanted the fully qualified URL (RawUrl gives you just the Path and Query part). So, to build on Josh's answer:

string originalUrlFull = 
   Page.Request.Url.GetLeftPart(System.UriPartial.Authority) + 
   Page.Request.RawUrl
answered 2011-09-21T01:23:22.057

Your Answer