小小的下载功能,问题多多
2013-10-12 11:43
309 查看
protected string LoadFiles() { StringBuilder strhtml = new StringBuilder(); if (Session["studentmodel"] != null) { Maticsoft.Model.Student model = (Maticsoft.Model.Student)Session["studentmodel"]; string filepath = CommonCode.GetDirPath(model.StudentType); Maticsoft.BLL.Submission bll = new Maticsoft.BLL.Submission(); if (bll.Exists(model.StudentId)) { Maticsoft.Model.Submission submodel = bll.GetModel(model.StudentId); string isexists = Server.MapPath("~/" + filepath + submodel.SubNewTitle); if (!File.Exists(isexists)) { return strhtml.Append("上传的文件已经移除").ToString(); } strhtml.Append("<span>"); strhtml.Append("文档下载:"); strhtml.Append("<a href='" + filepath + Server.UrlEncode(submodel.SubNewTitle) + "'>"); strhtml.Append("" + submodel.SubTitle + ""); strhtml.Append("</a>"); strhtml.Append("</span>"); return strhtml.ToString(); } else { return strhtml.Append("暂无上传").ToString(); } } else return strhtml.Append("暂无上传").ToString(); }
由于文件路径中有中文存在。Server.UrlEncode是一定要注意的,否则会有404找不到路径的错误。
放到服务器上,下载文件时又出现了新的错误。HTTP 错误 404.11 - Not Found 请求筛选模块被配置为拒绝包含双重转义序列的请求,
解决方案在这里
1.单击 开始 。 在 开始搜索 框中, 键入 Notepad. 右击 记事本 , 然后单击 作为管理员运行 。
注意 如果提示用于管理员密码或用于确认, 键入密码, 或单击 继续 。
2.在 文件 菜单上, 单击 打开 。 在 文件名 框中, 键入 %windir%\system32\inetsrv\config\applicationhost.config然后单击 打开 。
3.在 ApplicationHost.config 文件, 定位 文件中的 configuration/system.webServer/security/requestFiltering/下
<requestFiltering> 节点。大约360行
将<requestFiltering>
改为
<requestFiltering allowDoubleEscaping="true">
即可
相关文章推荐
- php的IMAP的应用实例(实现收发邮件、删除邮件、附件下载等功能,解决中文乱码问题)
- 使用struts2实现下载功能遇到的文件中文问题
- 用Struts2更好的实现文件的上传、下载功能以及解决中文名称问题
- iNeedle日志下载功能问题
- 用AxWebBrowser编写了一个小的浏览器,但是下载功能出问题了
- node下载功能csv乱码问题
- java日常问题之excel文件下载功能中getOutputStream() has already been called for this response
- 解决springmvc中文件下载功能中使用javax.servlet.ServletOutputStream out = response.getOutputStream();后运行出异常但结果正确的问题
- web后端--一个小小的下载和防盗链功能
- 使用struts2实现下载功能遇到的文件中文问题解决经验分享
- 乱码问题, (文件下载功能时, 下载不下来,编码要和服务器系统编码一致
- struts2 Annotation 实现文件下载功能 文件名中文乱码问题
- Microsoft Visual Studio 2015 下载、注册、安装过程、功能列表、问题解决
- struts2 Annotation 实现文件下载功能 文件名中文乱码问题
- Microsoft Visual Studio 2015 下载、注册、安装过程、功能列表、问题解决
- php的IMAP的应用实例(实现收发邮件、删除邮件、附件下载等功能,解决中文乱码问题)
- Android自带的下载功能,不需要断点续传、大文件下载、通知栏显示等窝心问题,四行代码全部搞定(经测)
- php的IMAP的应用实例(实现收发邮件、删除邮件、附件下载等功能,解决中文乱码问题)
- 文件下载功能相关的FireFox和IE的差异问题
- 手机端UC浏览器,在java开发的下载功能中存在的问题?