在网上看了一文章,说实现下载只要将资源的 url 放到叶面上就可以我这么做了但出现了错误:" The HTTP verb POST used to access path ' /WebSite/Upload/test1.rar 'is not allowed "请教诸位错误的原因、解决方法,以及使用ASP.NET实现下载的标准方法Thanks in advance.
解决方案 »
- 急。。。。。。SQL语句高手帮帮忙。。
- 高分求思路,如何从页面导出PPT
- 关于<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
- 大家帮顶下哈:NetTiers模版生成代码的一些疑问
- 求职:asp.net(C#),杭州市内,请斑主手下留情,别删贴,谢谢^_^
- 超怪问题,页面不执行后台代码
- [上传流操作] 求一个上传流操作,<input type=file...>的就不需要了.
- ASP.NET2.0中 在Login页面登录结束就直接到各自自己的页面,该怎么实现呢?谢谢!
- 判断某数据项是否为空时,若按钮里加上Javascript提示会造成整个页面变白。可否避免这种情况?
- 如何正确获取动态文本框的内容?
- table问题
- 我的aspx页面上有好多TextBox控件,需要让用户输入时间,用一个calendar可以实现吗?多谢。
一:直接用链接指向要下载的资源(就像楼主使用的方法)
二:先在服务器读入资源,然后以流的方式实现下载
如这里的函数
public static void FileDownload(HttpContext context, string FullFileName)
{
FileInfo DownloadFile = new FileInfo(FullFileName);
context.Response.Clear();
context.Response.ClearHeaders();
context.Response.Buffer = false;
context.Response.ContentType = "application/octet-stream";
//Response.ContentType = "application/ms-excel";
context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(DownloadFile.FullName, System.Text.Encoding.UTF8));
context.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
context.Response.WriteFile(DownloadFile.FullName); context.Response.Flush();
context.Response.End();
}