I am having this really weird issue with downloading files from within ASP.Net MVC (not downloading FROM the app, TO the app) and hope someone can help me out.
This bit of code running in a controller:
using (var wc = new WebClient())
{
var siteText = wc.DownloadString("http://www.google.com");
return siteText;
}
This returns the error:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 208.67.219.231:80
I have tried tons of other addresses with the same result, although "some" will let me through, but those are on the local network.
Is there a setting that I am missing to allow the website to access external sites?
Just of note, I have tried using an HttpWebRequest and setting the User Agent as well, same errors.
My environment is IIS 7.0 running in the Integrated Managed Pipeline. I have tried changing the identity of the application pool to be a user I can verify that has access to the internet as well.
Update This is also happening with images, and all other file types using either the WebClient or WebRequest.Create(url) methods, but ONLY in an ASP.Net application.