Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get current page from url

Tags:

c#

url

request

I want to write a c# method to retrieve the current page. eg Default6.aspx I know I can do the following:

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 

but how can I get Default6.aspx? And if the url is http://localhost:1302/TESTERS/, my method should return default.aspx

like image 615
amateur Avatar asked Jan 28 '11 16:01

amateur


People also ask

How do you get the current page URL?

Answer: Use the window. location. href Property location. href property to get the entire URL of the current page which includes host name, query string, fragment identifier, etc.

Which method return the URL of the current page?

The window.location.href property returns the URL of the current page.

How do I get the current page number in JavaScript?

var lighboxHeight = (pagenumber-1)*window.


1 Answers

Path.GetFileName( Request.Url.AbsolutePath ) 
like image 105
Paul Alexander Avatar answered Oct 05 '22 07:10

Paul Alexander