In order to get the url of current page C# code is :
string currUrl = Request.Url.AbsoluteUri;
It will display the full URL as:
http://localhost:61653/WebSite1/Default1.aspx
In order to get the absolute path of the url C# code is :
string currPage = Request.Url.AbsolutePath;
Output is as :
/WebSite1/Default.aspx
There might come a case by which we want to know url of the previous page from where
it is navigated.
In order to get the url of previous page C# code is :
string prevUrl = Request.UrlReferrer.AbsoluteUri;
This will display the full url of previous page.
And if we just want to know absolute path only the code is :
string prevPage = Request.UrlReferrer.AbsolutePath;
string currUrl = Request.Url.AbsoluteUri;
It will display the full URL as:
http://localhost:61653/WebSite1/Default1.aspx
In order to get the absolute path of the url C# code is :
string currPage = Request.Url.AbsolutePath;
Output is as :
/WebSite1/Default.aspx
There might come a case by which we want to know url of the previous page from where
it is navigated.
In order to get the url of previous page C# code is :
string prevUrl = Request.UrlReferrer.AbsoluteUri;
This will display the full url of previous page.
And if we just want to know absolute path only the code is :
string prevPage = Request.UrlReferrer.AbsolutePath;
No comments:
Post a Comment