Tuesday, January 15, 2019

How to Get the page url in asp.net c#

 <h2>Complete Web Page URL <br /></h2>
    <asp:Label ID="lblMessage" runat="server"></asp:Label>
   
 <h3>Web Page Name :- </h3>
 <asp:Label ID="lblPageName" runat="server"></asp:Label>

C# code :
            string url = HttpContext.Current.Request.Url.AbsoluteUri;
            lblMessage.Text = url;
            string[] urlArr = url.Split('/');
            string[] pageName = urlArr[urlArr.Length - 1].Split('.');
            lblPageName.Text = pageName[0];

Output:-


No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...