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
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.
The window.location.href property returns the URL of the current page.
var lighboxHeight = (pagenumber-1)*window.
Path.GetFileName( Request.Url.AbsolutePath )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With