Ho problemi a ottenere la configurazione automatica del proxy (PAC) nelle opzioni di IE per funzionare come previsto utilizzando .Net WebRequest.Utilizzo della configurazione automatica del proxy dalle impostazioni IE in .Net
Secondo questo articolo:
Proxy Detection Take the Burden Off Users with Automatic Configuration in .NET
La delega di sistema deve essere impostato di default con a ciascun WebRequest.
Ecco come il file pac proxy.js assomiglia:
function FindProxyForURL(url, host)
{
return "PROXY ProxyServerName:3118; DIRECT;";
}
Ho anche preso uno sguardo a questo post: How should I set the default proxy to use default credentials?
Il che suggerisce di aggiungere questo nel app.config:
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
L'aggiunta di questo non ha aiutato.
ho creato una piccola applicazione console solo per testare il tutto .. eccolo:
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");
}
}
L'output: proxy per l'indirizzo è http://www.google.com
invece di proxy per l'indirizzo è ProxyServerName: 3118
succede solo quando si utilizza script di configurazione automatica ...
mi sono perso qualcosa? Per favore aiuto!
Il problema era con il mime-type – bondar