Skip to content

Instantly share code, notes, and snippets.

@fernyettheplant
Created July 2, 2015 18:43
Show Gist options
  • Save fernyettheplant/5252f458c52b068f18cf to your computer and use it in GitHub Desktop.
Save fernyettheplant/5252f458c52b068f18cf to your computer and use it in GitHub Desktop.
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