簡體   English   中英

Chome下載aspx頁面,而不是像IE和firefox一樣下載Excel

[英]Chome downloads aspx page instead of an excel like it does in IE and firefox

我有一個網頁,允許用戶下載Excel報表,在Chrome中,它只是嘗試下載一個aspx頁面,而不是像在IE和Firefox中一樣成功下載excel。

這是一個已知問題,是否有解決方法?

我在VB中使用它:

db.subRunReader(resultSQL)
dgProperties.DataSource = db.sqlReader
dgProperties.DataBind()
db.subCloseReader()
db.subCloseConnection()

Response.ContentType = "application/vnd.ms-excel"
Response.Charset = ""
Me.EnableViewState = False

Dim tw As New System.IO.StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)
dgProperties.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
Response.Redirect(Request.Url.ToString())

謝謝。

不確定您的具體情況,但是通常在您希望下載文件時,最好添加Content-Disposition標頭。 在ASP.NET MVC中,將這樣完成:

Response.Headers["Content-Disposition"] = 
    "attachment;filename=yourfile.xls";

我期望在ASP.NET 2.0中會類似。 這告訴瀏覽器它需要下載文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM