Friday, April 03, 2009

I want to use Path.Combine for Urls!

So I admit, I am a WinForms guy in a WebForms world so I knew what I wanted but not where to look.

All I wanted to do was take a known http host and combine it relative url. Both our main web developers didn't know the answer and there was no common library to handle it. The best I got was to use Path.Combine and then replace the \ with a /.

I was sure that was a horrible hack and if I ever did that the little Travis in my head would scoff at me and make me feel bad.

So after some more digging I found the answer in System.Web. The VirtualPathUtility.Combine() method does exactly what Path.Combine does, except for non local paths.

Some days avoiding Travis is easier than others, today was a good day.

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.