Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Current Page's Url in asp.net using code behind technique?

Tags:

url

asp.net

I want to get Url of the page like abc.aspx. how can i get this using code behind technique. Any idea.?

like image 928
Ram Singh Avatar asked Feb 04 '12 07:02

Ram Singh


3 Answers

Full Details, you can later use string Operations for advanced manipulation:

string url = HttpContext.Current.Request.Url.AbsoluteUri;
// http://localhost:1302/TESTERS/Default6.aspx

string path = HttpContext.Current.Request.Url.AbsolutePath;
// /TESTERS/Default6.aspx

string host = HttpContext.Current.Request.Url.Host;
// localhost

How to get the URL of the current page in C#

like image 120
Muhammad Omar ElShourbagy Avatar answered Oct 17 '22 07:10

Muhammad Omar ElShourbagy


Use Request.RawUrl:

Gets the raw URL of the current request.

like image 23
Oded Avatar answered Oct 17 '22 09:10

Oded


Request.RawUrl property gives you the fully qualified URL of your current page

like image 28
Sunil Kumar B M Avatar answered Oct 17 '22 09:10

Sunil Kumar B M