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

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!

Leave a Reply