AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Monday 26 October 2015

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&paramerter3=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
I hope this article will helpful for you.

   1 comment :

  1. 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?
    do I need more libraries? and if is that the problem, which ones I need?
    thaks for answer :)

    ReplyDelete

  • Popular Posts
  • Comments