0

Just to make myself clear - I am looking for an ASP.NET MVC solution, not a java one.

I have lot of image Urls in my site and I need to determine whether they are relative paths of the web application or absolute paths.

If the Url is relative path I can call a function that generates an absolute path from the relative one.

If the Url is external path it means its already the full absolute path and therefore this function call is not needed.

I thought about checking if the string starts with "http" or "www" and than it means its an absolute path, but it doesn't match all the options like zaza-bu.blala.fr/coolimage.png.

The only thing I have that can work is just trying to access the Url generated after this function. if the Url is accessable - than it was relative and the Url is valid, If not - it was a an absolute path, and I need to take the string before the function call, but its too hacky and slow.

I am using c# ASP.NET 4 for that.

Thanks in advance.

Aviran Cohen
  • 5,581
  • 4
  • 48
  • 75
  • And what language does it need to be in? – Tyil Sep 29 '12 at 19:55
  • Here is a good answer to your question: [StackOverflow: determine if a string is absolute URL or a relative URL](http://stackoverflow.com/questions/4390800/determine-if-a-string-is-absolute-url-or-relative-url-in-java) – paulsm4 Sep 29 '12 at 19:58
  • Weird I forgot to mention, i am working with C# / ASP.NET MVC – Aviran Cohen Sep 29 '12 at 23:25

0 Answers0