Answers and code snippets from ASP.NET projects (Webforms/MVC/Classic ASP)
In web form page, add:
protected void Page_PreInit(object sender, EventArgs e)
{
this.Page.MasterPageFile = "~/name.master";
}
public string GetCurrentPageName() { string Path = System.Web.HttpContext.Current.Request.Url.AbsolutePath; System.IO.FileInfo fInfo = new System.IO.FileInfo(Path); return fInfo.Name; }