Tuesday 7 October 2008

System.Web.VirtualPathUtility to get File Names from Urls and Converting Relative Paths to Absolute Urls (without ResolveUrl)

One of the things that appeared to be lacking in ASP.NET 2.0 and above (or so I thought) is a utility library to parse and extract paths and get the file name from a Url. Here are some examples of the url parsing code that I and others have done without knowledge of this library: http://www.thejackol.com/2007/04/10/get-file-name-from-url-cnet/
and http://www.west-wind.com/Weblog/posts/154812.aspx

One class that does just this (and which most developers don't know about) is System.Web.VirtualPathUtility(). Everyone knows it's brother utility library System.Web.HttpUtility but VirtualPathUtility should be an essential part of any ASP.NET developer's toolkit. See http://msdn.microsoft.com/en-us/library/system.web.virtualpathutility.aspx for more information.


Unknown said...

Just be warned: it won't support any paths with querystrings included...

Anonymous said...

Can anyone recommend the top Remote Management system for a small IT service company like mine? Does anyone use Kaseya.com or GFI.com? How do they compare to these guys I found recently: N-able N-central remote support
? What is your best take in cost vs performance among those three? I need a good advice please... Thanks in advance!