I am getting exception(The remote server returned an error: (500) Internal Server Error.) for request.GetResponse() if I deploy application in different port other than 80(default), when I try to access the URL , it is working fine.
I had followed many suggestions from "Stackoverflow" and google. still I am getting the error with the below code
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;
}
Thanks,
Pavan