C# 404更改app.config中的默认代理地址后出错
我想使用c中的WebClient连接到internet# 连接成功,但在app.config中更改代理配置后停止工作 这是配置C# 404更改app.config中的默认代理地址后出错,c#,proxy,app-config,C#,Proxy,App Config,我想使用c中的WebClient连接到internet# 连接成功,但在app.config中更改代理配置后停止工作 这是配置 <system.net> <defaultProxy enabled="true"> <proxy proxyaddress="http://192.168.10.33"/> </defaultProxy> </system.net> 这就是我连接互联网的方式 public async T
<system.net>
<defaultProxy enabled="true">
<proxy proxyaddress="http://192.168.10.33"/>
</defaultProxy>
</system.net>
这就是我连接互联网的方式
public async Task<T> PostAsync<T>(string uri, NameValueCollection pairs)
{
byte[] response = null;
using (WebClient client = new WebClient())
{
try
{
response = await Task<byte[]>.Factory.StartNew(() =>
{
return client.UploadValues(uri, pairs);
});
}
catch (WebException e)
{
Trace.WriteLine(e);
response = null;
}
}
if (response != null)
{
string resultAsString = System.Text.Encoding.UTF8.GetString(response);
T result = JsonConvert.DeserializeObject<T>(resultAsString);
return result;
}
return default(T);
}
公共异步任务PostAsync(字符串uri、NameValueCollection对)
{
字节[]响应=null;
使用(WebClient=newWebClient())
{
尝试
{
响应=等待任务。工厂。开始新建(()=>
{
返回client.uploadValue(uri,对);
});
}
捕获(WebE例外)
{
Trace.WriteLine(e);
响应=空;
}
}
if(响应!=null)
{
string resultAsString=System.Text.Encoding.UTF8.GetString(响应);
T result=JsonConvert.DeserializeObject(resultAsString);
返回结果;
}
返回默认值(T);
}
您的代理服务器是否在特定端口上运行和/或使用代理身份验证?@uteist我不确定如何验证这一点,但我可以告诉您,这是我们网络域上共享服务器的IP。我想,这很可能不是代理服务器,而只是一个共享。无论如何,为什么在配置中需要代理?实际要求是什么?