服务器中的下载问题 [英] downloading problem in server
本文介绍了服务器中的下载问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
要下载文件,以下代码可在localhost上运行,但不能在Web服务器上运行.你能帮忙吗?
To download file, the following code works on localhost but not working on Web server. Can you help please?
string path = "ftp://mysite.in:21/" + filename;
WebClient request = new WebClient();
request.Credentials = new NetworkCredential("usrname", "password");
byte[] filedata = request.DownloadData(path);
FileStream file = File.Create(foldername + "/" + filename);
file.Write(filedata, 0, filedata.Length);
file.Close();
推荐答案
IIS 6& Web服务器内置的Visual Studio注册的内容与IIS 7有所不同.如果主机运行的是IIS 7,则可能需要将注册添加到< system.webserver>中. Web.config文件中的节点.
IIS 6 & the Visual Studio built in Web Server register things a bit differently than IIS 7. If your host is running IIS 7, you may need to add your registration to the <system.webserver> node in your Web.config file.
<system.webServer>
<handlers>
<add ... />
</handlers>
</system.webServer>
这篇关于服务器中的下载问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文