Friday, February 9, 2007

Getting the ASPX File Name

I only used this once, and quickly changed my approach so I didn't need to rely on it, but here's how you can get the name of the ASPX file you're viewing.
string pageName = this.Page.GetType().Name.Replace("_", ".");
Of course, there's also
Request.ServerVariables["SCRIPT_NAME"]
and
HttpContext.Current.Request.Path
and
System.IO.Path.GetFileNameWithoutExtension(Request.FilePath)

No comments: