简体   繁体   English

为什么request.GetResponse()在不同端口(!= 80)网址上抛出“远程服务器返回错误:(500)”?

[英]Why request.GetResponse() throwing “remote server returned an error: (500) ” on different port(!=80) urls?

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. 如果我尝试将应用程序部署到除80(默认)以外的其他端口时,我收到request.GetResponse()的异常(远程服务器返回错误:(500)内部服务器错误。),则当我尝试访问URL时,工作正常。

I had followed many suggestions from "Stackoverflow" and google. 我遵循了“ Stackoverflow”和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 帕万

This is usually an issue on the server side and should have nothing to do with your application. 这通常是服务器端的问题,应该与您的应用程序无关。

That said, have you tried to access the same url from your computer / device (via chrome or IE) with the other port? 也就是说,您是否尝试过使用其他端口从计算机/设备(通过Chrome或IE)访问相同的url

If it works on other devices, then you should check your device's setup; 如果它可以在其他设备上使用,则应检查设备的设置; but I still think it's an issue on the server. 但我仍然认为这是服务器上的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 获取错误“远程服务器返回错误:(400)错误请求。”在线WebResponse response = request.GetResponse(); - Getting error “ The remote server returned an error: (400) Bad Request.” on line WebResponse response = request.GetResponse(); request.getResponse()出现错误 - request.getResponse() is getting error 调用GetResponse()引发(500)内部服务器错误 - Call to GetResponse() is throwing (500) Internal Server Error 远程服务器返回错误:(500)System.Net.HttpWebRequest.GetResponse()上的服务器上的内部服务器错误 - The remote server returned an error: (500) Internal Server Error on server at System.Net.HttpWebRequest.GetResponse() (HttpWebResponse)request.GetResponse()抛出操作已超时 - (HttpWebResponse)request.GetResponse() throwing The operation has timed out C# - request.GetResponse() - C# - request.GetResponse() 为什么(HttpWebResponse)request.GetResponse()方法返回错误页面的状态码200? - why (HttpWebResponse)request.GetResponse() method returning status code 200 for Error Page? request.getresponse()给出错误的错误用户名和密码 - request.getresponse() giving error bad username and password 如何使用cookie request.getresponse() - How to request.getresponse() with cookie 在 c# WebResponse response = request.GetResponse() 上出现未经授权的错误; - Getting Unauthorized error on c# WebResponse response = request.GetResponse();
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM