简体   繁体   English

从ASP.NET MVC Web应用程序下载文件时出错

[英]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.

相关问题 将文件从Internet下载到ASP.NET MVC Web应用程序 - Downloading a file from internet to ASP.NET MVC web application 从 Web 应用程序下载文件问题 - ASP.NET Web 表单应用程序 - Issue downloading Files from Web App - ASP.NET Web Form Application 从Asp.Net Mvc中的数据库下载文件 - Downloading files from the database in Asp.Net Mvc 在ASP.NET MVC中下载文件时出错 - Error in downloading a file in ASP.NET MVC asp.net MVC 4 Web应用程序“ /”应用程序中的服务器错误? - asp.net MVC 4 web application Server Error in '/' Application? asp.net mvc Web应用程序错误“无法将数据库作为...附加” - asp.net mvc web application error “cannot attach database … as … ” 如何将文件从Web下载到ASP.NET Web应用程序中? - How to download files from web into an ASP.NET Web Application? 如何在不将文件下载到Web服务器的情况下使用asp.net mvc将文件传送到客户端? - How to work with file delivery to the client in asp.net mvc without downloading the files on the web server? 从我的asp.net mvc Web应用程序调用asp.net控制台应用程序 - Calling an asp.net console application from my asp.net mvc web application 将ASP.NET MVC Web应用程序从http转换为https - Convert ASP.NET MVC web application from http to https
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM