[英]Error downloading files from asp.net mvc web application
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. 我在从ASP.Net MVC中下载文件时遇到了一个非常奇怪的问题(不是从应用程序下载到应用程序),希望有人能帮助我。
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 System.Net.WebException:无法连接到远程服务器---> System.Net.Sockets.SocketException:无法建立连接,因为目标计算机主动拒绝了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. 值得注意的是,我尝试使用HttpWebRequest并设置用户代理,同样的错误。
My environment is IIS 7.0 running in the Integrated Managed Pipeline. 我的环境是在集成托管管道中运行的IIS 7.0。 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.
我尝试将应用程序池的身份更改为用户,我可以验证自己是否也可以访问Internet。
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. 更新对于图像以及使用WebClient或WebRequest.Create(url)方法的所有其他文件类型,也是如此,但仅限于ASP.Net应用程序中。
This exception means that either a firewall or a remote computer is actively blocking your connection attempts. 此异常意味着防火墙或远程计算机正在主动阻止您的连接尝试。
Rather than looking at permissions/user agents you should investigate the network setup of that server. 与其查看权限/用户代理,不如调查该服务器的网络设置。 Can it connect directly to the internet without proxy?
无需代理即可直接连接到互联网吗? Do you have a proxy configured in IE?
您在IE中配置了代理吗?
Try for example the command line 尝试例如命令行
telnet stackoverflow.com 80
Does it connect or do you get a connection refused as well? 它是否连接或您是否也拒绝连接?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.