URL Details of Current Page in ASP.NET C#?
Many times need to get different values from URL so here i am going to show you extract different parts of url.
Example URL:
http://localost:5266/SiteWeb/Dashboard.aspx?paramerter1=one&Parameter2=two¶merter3=three
Table
I hope this article will helpful for you.
Example URL:
http://localost:5266/SiteWeb/Dashboard.aspx?paramerter1=one&Parameter2=two¶merter3=three
Table
Code | OutPut | Comment |
HttpContext.Current.Request.Url.Host | localhost | It will return Site Host name |
HttpContext.Current.Request.Url.AbsolutePath | SiteWeb/Dashboard.aspx | It will return relative URL |
HttpContext.Current.Request.Url.Authority | localost:5266 | It will return Host |
HttpContext.Current.Request.ApplicationPath | /SiteWeb | It will return Application URL |
HttpContext.Current.Request.Url.AbsoluteUri | http://localost:5266/SiteWeb/Dashboard.aspx?paramerter1=one&Parameter2=two&paramerter3=three | It will return absolute path |
HttpContext.Current.Request.Url.PathAndQuery | /SiteWeb/Dashboard.aspx?paramerter1=one&Parameter2=two&paramerter3=three | It will return rest after host name |
ASP.NET , C# , Visual Basic
Hello, I have a litle problem, when I write the String to get the URL Visual Studio shows a message error that .Request doesn't exist. what should I do?
ReplyDeletedo I need more libraries? and if is that the problem, which ones I need?
thaks for answer :)