10

I need to be able to get the URL as I see it in the browser i.e The rewritten one. For instance:

If my Url was www.myurl.com/Test.html and I then used Request.Url.AbsoluteUri, the URL returned would be: www.myurl.com/Default.aspx?Action=Test

I need to be able to get back the exact rewritten URL.

Does anyone know how I can achieve this?

casperOne
  • 73,706
  • 19
  • 184
  • 253
webnoob
  • 15,747
  • 13
  • 83
  • 165
  • Thanks for the edit, didn't realise you could do inline code tags. – webnoob Aug 03 '10 at 09:03
  • 3
    Have you tried Request.RawUrl? I think that gives you the unmapped URL. – Tchami Aug 03 '10 at 09:20
  • That provides enough for me to be able to build the url: i.e it returns /Test.html to which as it happens, is the bit I really need anyway. Can you make an answer post please so I can mark it as such. – webnoob Aug 03 '10 at 10:07

2 Answers2

6

From Tchami:

Have you tried Request.RawUrl? I think that gives you the unmapped URL.

Will mark this as the answer when I am allowed.

webnoob
  • 15,747
  • 13
  • 83
  • 165
0

You could rewrite the URL so, that it includes the original URL as a querystring parameter.

For example: url="(.*)" to="http://newurl.com?original=$1".
(Note you'll still have to adjust the regex to work with URLs that contain a querystring.)

Protector one
  • 6,926
  • 5
  • 62
  • 86