-1

Possible Duplicate:
Get URL of ASP.Net Page in code-behind

I'm trying to hold current url in string in the code behind.

as example this is the current url address:http:www.stackoverflow.com/questions/ask/submit how I can hold this in string variable?

please help me out.

Community
  • 1
  • 1
user1298676
  • 97
  • 1
  • 2
  • 8

1 Answers1

11

This will get you the full URL:

Request.Url.AbsoluteUri
Curtis
  • 101,612
  • 66
  • 270
  • 352
  • 1
    What if i have '#' in URL..... i.e :http:test.abc.com/sitesposure.aspx#commentfocus......... will it work? – Pranav Bilurkar Jan 27 '15 at 14:54
  • 1
    @Pranav-BitWiser - No, hash parameters are front end only. If you wish to access this back-end then AJAX is a good option. See my blog post on how to read hash tag values: http://curtistimson.co.uk/js/reading-url-hashtag-values/ – Curtis Jan 27 '15 at 15:30