Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 904
jessegavin Avatar asked Mar 11 '10 18:03

jessegavin


People also ask

How to rewrite URL in. net Core?

A URL rewrite is a server-side operation that provides a resource from a different resource address than the client requested. Rewriting a URL doesn't require a round trip to the server. The rewritten URL isn't returned to the client and doesn't appear in the browser's address bar.

What is rewrite path?

The RewritePath(String) method redirects a request for a resource to a different path than the one that is indicated by the requested URL.

What is URL rewriting in MVC?

URL rewriting is the process of intercepting an incoming Web request and redirecting the request to a different resource. When performing URL rewriting, typically the URL being requested is checked and, based on its value, the request is redirected to a different URL.


1 Answers

Try this:

string originalUrl = HttpContext.Current.Request.RawUrl;

The original URL is inside of this property.

like image 101
Colin Breame Avatar answered Oct 11 '22 03:10

Colin Breame