Reputation: 682
I have an MVC4 application that is using Windows authentication. This application scrapes a variety of internet sites. This application is hosted in our intranet and needs to go through our corporate proxy to access the internet. Through some debugging I can see that I'm fully authenticated by user id and that I'm impersonating. My problem is that I keep receiving error The remote server returned an error: (407) Proxy Authentication Required.
. I can verify that my code works because it works as expected if I hard code my credentials for the proxy.
var windowsIdentity = (WindowsIdentity) HttpContext.Current.User.Identity;
using (windowsIdentity.Impersonate())
{
var webClient = new WebClient
{
Proxy = new WebProxy(PROXY)
{
Credentials = CredentialCache.DefaultNetworkCredentials
}
};
var str = webClient.DownloadString("http://google.com");
}
Using CredentialCache.DefaultCredentials
also does not work. Why can't I impersonate myself (or whoever is accessing the site) and use that user to authenticate against the proxy?
Upvotes: 0
Views: 1706
Reputation: 175
The proxy settings of the server are probably ignored. Try reading this.
Upvotes: 1