c#WebRequest仅适用于代理

c#WebRequest仅适用于代理,c#,httpwebrequest,C#,Httpwebrequest,我试图向API发出POST请求,但它最终超时。如果我通过代理运行它,它将按预期工作,因此我不知道如何确定要去哪里 string url = "https://" + this.Host + ":1234" + uri; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; //request.Proxy = new WebProxy ("127.0.0.1", 8080)

我试图向API发出POST请求,但它最终超时。如果我通过代理运行它,它将按预期工作,因此我不知道如何确定要去哪里

string url = "https://" + this.Host + ":1234" + uri;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
//request.Proxy = new WebProxy ("127.0.0.1", 8080);

request.ContentType = "application/json";

string response = string.Empty;
try
{
    using (StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream()))
        response = reader.ReadToEnd();
}

您是否尝试过使用其他应用程序来检查同一台计算机的URL?@VincentP我没有开发API,我可以在常规浏览器中从同一台计算机调用API。这与CORS有关。如果api未使用跨源资源共享或JSONP,则无法对其域外的api进行调用。@allencage如果其CORS,则无法调用该api。当通过代理运行或在浏览器中手动执行api调用时,api调用是如何工作的?