aspx中放置了一个<asp:ImageButton ID="BtnDownload" runat="server" ImageUrl="~/Images/Download.gif" BorderColor="Blue" BorderStyle="Solid" />其后台代码为:
Protected Sub BtnDownload_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles BtnDownload.Click
Response.Redirect("~/Download.aspx?fiName=" & System.Web.HttpUtility.UrlEncode("~/Software/Sports/体育图片.rar"))
End Sub而Download.aspx的后台代码为:
Imports System.IO
Partial Class Download
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim path As String = Server.MapPath(Request.Params("fiName"))
Dim file As New FileInfo(path)
Response.Clear() Response.Charset = "UTF-8"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AddHeader("Content-Disposition", "attachment;filename=" & HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8)) Response.AddHeader("Content-Length", file.Length.ToString)
Response.ContentType = "application/octet-stream" Response.WriteFile(file.FullName)
Response.End()
End Sub
End Class点击BtnDownload,弹出保存文件对话框,在IE中文件名正常,而在FoxFire中却再现乱码,不知该如何解决?
Protected Sub BtnDownload_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles BtnDownload.Click
Response.Redirect("~/Download.aspx?fiName=" & System.Web.HttpUtility.UrlEncode("~/Software/Sports/体育图片.rar"))
End Sub而Download.aspx的后台代码为:
Imports System.IO
Partial Class Download
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim path As String = Server.MapPath(Request.Params("fiName"))
Dim file As New FileInfo(path)
Response.Clear() Response.Charset = "UTF-8"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AddHeader("Content-Disposition", "attachment;filename=" & HttpUtility.UrlEncode(file.Name, System.Text.Encoding.UTF8)) Response.AddHeader("Content-Length", file.Length.ToString)
Response.ContentType = "application/octet-stream" Response.WriteFile(file.FullName)
Response.End()
End Sub
End Class点击BtnDownload,弹出保存文件对话框,在IE中文件名正常,而在FoxFire中却再现乱码,不知该如何解决?
解决方案 »
- 上传文件
- csdn的csrf漏洞
- 数据结构的迷惑
- 怎么控制textBox只能输入小数点后4位?
- C#.NET中播放数据库中以二进制数存放的.MP3或者.WAV文件
- C#中,怎样往SQL数据库中写入格式为2006-03-02这样的格式的当前时间?
- 求一正则表达式
- 请教达人:有关ASP报错:“ASP.default_aspx”并不包含“MyMenu_MenuItemClick”的定义
- google搜索栏下拉效果
- 为何在win2003下安装vs.net2003后无法打开.aspx文件!急
- asp.net网站在局域网内发布后,远程访问该网站时快,时慢是怎么回事?
- ensurechildcontrols方法
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim path As String = Server.MapPath(Request.Params("fiName"))
Dim file As New FileInfo(path)
Response.Clear() Dim filename As String
If Request.UserAgent.Contains("MSIE") Then
filename = HttpUtility.UrlEncode(file.Name, Encoding.UTF8)
Else
filename = Convert.ToBase64String(Encoding.UTF8.GetBytes(file.Name))
filename = "=?UTF-8?B?" & filename & "?="
End If Response.Charset = "UTF-8"
Response.ContentEncoding = System.Text.Encoding.UTF8
Response.AddHeader("Content-Disposition", "attachment;filename=" & filename) Response.AddHeader("Content-Length", file.Length.ToString)
Response.ContentType = "application/octet-stream" Response.WriteFile(file.FullName)
Response.End()
End Sub