我有一个返回自定义404页面的网站,我需要获取它的源代码并确定它返回的是哪种404。有没有办法获得404页面的源代码?
try
{
using (var webClient = new WebClient())
{
webClient.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0)");
webClient.DownloadFile(new Uri(file.Address), file.SaveLocation);
}
}
catch (WebException e)
{
// read source code here...
}