仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 497|回复: 9
打印 上一主题 下一主题

[学习教程] ASP网站制作之使用XMLHTTP下载文件

[复制链接]
萌萌妈妈 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 22:25:49 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧使用XMLHTTP下载文件,和之前的办法一样,先增加援用-COM-MicrosoftXml3.0,然后在代码入手下手处写:
usingMSXML2;
上面就是次要的代码:
privatevoidPage_Load(objectsender,System.EventArgse)
{
stringUrl="";
stringStringFileName=Url.Substring(Url.LastIndexOf("/")+1);
stringStringFilePath=Request.PhysicalApplicationPath;
if(!StringFilePath.EndsWith("/"))StringFilePath+="/";
MSXML2.XMLHTTP_xmlhttp=newMSXML2.XMLHTTPClass();
_xmlhttp.open("GET",Url,false,null,null);
_xmlhttp.send("");
if(_xmlhttp.readyState==4)
{
if(System.IO.File.Exists(StringFilePath+StringFileName))
System.IO.File.Delete(StringFilePath+StringFileName);
System.IO.FileStreamfs=newSystem.IO.FileStream(StringFilePath+StringFileName,System.IO.FileMode.CreateNew);
System.IO.BinaryWriterw=newSystem.IO.BinaryWriter(fs);
w.Write((byte[])_xmlhttp.responseBody);
w.Close();
fs.Close();
Response.Write("文件已失掉。<br><ahref="+Request.ApplicationPath+StringFileName+"target=_blank>");
Response.Write("检察"+StringFileName+"</a>");
}
else
Response.Write(_xmlhttp.statusText);
Response.End();
}


楼上说交互性不好,太牵强了吧。在微软提供的一套框架中,利用asp做网站,开发效率高,使用人数少,减少不必要的开销。交互性是互动方式,是有开发人员决定的。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-30 19:58

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表