Tôi gặp sự cố khi nhận Cấu hình Tự động Proxy (PAC) trong các tùy chọn của IE để hoạt động như mong đợi khi sử dụng .Net WebRequest.Sử dụng Cấu hình Tự động Proxy từ Cài đặt IE trong .Net
Theo bài viết này:
Proxy Detection Take the Burden Off Users with Automatic Configuration in .NET
proxy hệ thống nên được thiết lập theo mặc định với từng WebRequest.
Đó là cách các proxy.js pac tập tin trông giống như:
function FindProxyForURL(url, host)
{
return "PROXY ProxyServerName:3118; DIRECT;";
}
Tôi cũng đã xem xét bài đăng này: How should I set the default proxy to use default credentials?
Những gợi ý để thêm video này trong app.config:
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
Việc này không giúp ích gì.
Tôi tạo ra một ứng dụng giao diện điều khiển nhỏ chỉ để kiểm tra điều này ra .. ở đây là:
static void Main(string[] args)
{
HttpWebRequest request = null;
try
{
String resolvedAddress = WebRequest.DefaultWebProxy.GetProxy(new Uri("http://www.google.com")).ToString();
Console.WriteLine("Proxy for address is: " + resolvedAddress);
Uri m_URLToTest = new Uri("http://www.google.com");
request = WebRequest.Create(m_URLToTest) as HttpWebRequest;
request.Method = "GET";
request.KeepAlive = false;
request.Timeout = 5000;
request.Proxy = WebRequest.DefaultWebProxy;
WebResponse response = request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());
string message = reader.ReadToEnd();
}
catch (Exception ex)
{
Console.Write("Exception");
}
}
Sản lượng: Proxy cho địa chỉ là http://www.google.com
thay vì Proxy cho địa chỉ là ProxyServerName: 3118
Chỉ xảy ra khi sử dụng tập lệnh cấu hình tự động ...
Tôi có bỏ lỡ bất cứ điều gì không? Hãy giúp tôi!
Vấn đề là với mime-type – bondar