Проверьте, существует ли файл с помощью url-адреса
How to check file exists using url, normally we have to use file exists controller on server like File.Exists() its working but url path like http://localhost:8081/assets/photos/test.jpg is not working. Please anyone explain ASAP
Что я уже пробовал:
var url = "http://www.domain.com/image.png"; HttpWebResponse response = null; var request = (HttpWebRequest)WebRequest.Create(url); request.Method = "HEAD"; try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException ex) { /* A WebException will be thrown if the status of the response is not `200 OK` */ } finally { // Don't forget to close your response. if (response != null) { response.Close(); } }
Richard MacCutchan
Что происходит, когда вы запускаете этот код?
Sinisa Hajnal
Так...в чем же проблема?