Getting The Current File Name in Vb.Net

Some times you need to figure out what the actual file name is a the web page that you are on.  If this is the case, here is the easy way to do this in the code behind:

Dim myPage As String = System.IO.Path.GetFileName(System.Web.HttpContext.Current.Request.Url.AbsolutePath)

If you are on a page, myPage will have just the page name in it (i.e. for the default page the value would be default.aspx).


Leave a Comment

Spam protection by WP Captcha-Free