What object can I use to get the current PageName.aspx (including the extension .aspx) from the URL? I can't find what object and method to allow me to grab this when I'm on a page.
See Question&Answers more detail:osWhat object can I use to get the current PageName.aspx (including the extension .aspx) from the URL? I can't find what object and method to allow me to grab this when I'm on a page.
See Question&Answers more detail:osNote that sometimes, on shared hosting like GoDaddy, you might not have the permission to create a new FileInfo
object. Yes, believe it.
So I suggest you use this snippet:
string fullPath = /* System.Web.HttpContext.Current. (optional in most cases) */ Request.Url.AbsolutePath;
string fileName = System.IO.Path.GetFileName(fullPath);
Enjoy :-)