How to get the name of the current executing ASP.NET page ?

Dec 12, 2009 Posted by Lara Kannan
To get the name of the executing ASP.NET Page from server-side code by using the namespace called System.IO.FileInfo.

See the below pices of C# code which will return the current executing asp.net page like default.aspx, home.aspx.
string sPagePath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;

System.IO.FileInfo oFileInfo = new System.IO.FileInfo(sPagePath);
tring sPageName = oInfo.Name;

I hope this will help you. A 'Thank You' would be nice!

Share
Labels: , ,

Post a Comment