Created
July 2, 2015 18:43
-
-
Save fernyettheplant/5252f458c52b068f18cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string imagenDefault = "/Content/imagenes/productos/default_box_art.jpg"; | |
public static string ImageOrDefault(this HtmlHelper helper, string urlImagen) | |
{ | |
try | |
{ | |
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(urlImagen); | |
request.Method = "HEAD"; | |
request.GetResponse(); | |
return urlImagen; | |
} | |
catch | |
{ | |
return imagenDefault; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment