我收到异常(远程服务器返回错误:(500)内部服务器错误。)如果我将应用程序部署在 80(默认)以外的其他端口,当我尝试访问 URL 时,它是工作正常。
我听从了“Stackoverflow”和谷歌的许多建议。我仍然收到以下代码的错误
private bool Ping(string url, out string message)
{
message = string.Empty;
try
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
request.Credentials = CredentialCache.DefaultCredentials;
request.Timeout = 3000;
request.AllowAutoRedirect = false;
request.Method = "HEAD";
using (WebResponse response = request.GetResponse())
{
return true;
}
}
catch (Exception ex)
{
message = ex.Message;
}
return false;
}
谢谢,
帕万