Я хочу получить html страницы с исходным кодом:
try {
var webContent = "";
using (WebClient client = new WebClient ()) {
client.Headers.Add (HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36");
webContent = client.DownloadString (@"http://localhost:8080/account/login");
}
} catch (WebException ex) {
var responseText = string.Empty;
var responseStream = ex.Response?.GetResponseStream ();
if (responseStream != null) {
using (var reader = new System.IO.StreamReader (responseStream)) {
responseText = reader.ReadToEnd ();
}
}
}
Я могу получить содержимое http://localhost:8080/. Но с http://localhost:8080/account/login, возвращается «Cannot GET / account/авторизоваться".Я могу просмотреть этот URL через браузер.
Как я могу получить html http://localhost:8080/account/login, используя WebClient?
Спасибо,