1

これは asp.net 3.5 Web サイトです。

ファイルは IE/FF で正しくダウンロードできます。しかし、クロムではありません。

ファイルは「ASPS_Page_Name.aspx」としてダウンロードされます。

ただし、Chrome ブラウザーを 20.0.1132.47 m に更新する前は機能していました。

MIMEタイプを除外するこの機能があります(ffを対象としており、以前のクロムはこの機能を必要としません)

Private Shared Function GetContentType(ByVal fileType As String) As String

    Select Case fileType

        'set to "application/vnd.ms-excel" MIME type for firefox
        'MIME Types for IIS
        Case "xls"
            Return "application/vnd.ms-excel"

        Case "xlsx"
            Return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"

        Case "pdf"
            Return "application/pdf"

        Case "doc"
            Return "application/msword"

        Case "docx"
            Return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"

        Case "ppt"
            Return "application/vnd.ms-powerpoint"

        Case "pptx"
            Return "application/vnd.openxmlformats-officedocument.presentationml.presentation"

        Case Else
            Return "application/octet-stream"

    End Select

End Function

現時点では、この機能を使用して xls/xlsx/pdf/.. ファイルを正しい名前でダウンロードできます。ダウンロードを機能させるために、ここまたは web.config ですべての MIME タイプを指定する必要があるかどうか疑問に思っています。

クロムに何が起こったのか、この「バグ」を修正する方法を知っている人はいますか?

これはダウンロード機能です。以前は機能していたので問題ありません。

Public Shared Sub StreamFileToClient(ByVal memoryStream As IO.MemoryStream, ByVal fileName As String, ByVal fileType As String)

    Try

        memoryStream.Position = 0

        'Serve to client
        System.Web.HttpContext.Current.Response.ClearHeaders()
        System.Web.HttpContext.Current.Response.ClearContent()

        System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;attachment; filename=" & fileName & "." & fileType)
        System.Web.HttpContext.Current.Response.AddHeader("Content-Length", memoryStream.Length.ToString())
        System.Web.HttpContext.Current.Response.ContentType = GetContentType(fileType)

        'octet-stream";
        System.Web.HttpContext.Current.Response.BinaryWrite(memoryStream.ToArray)
        'System.Web.HttpContext.Current.Response.Flush()
        'well good to use completerequest rather than .end nand .close. Read MSDN.
        'System.Web.HttpContext.Current.Response.End()
        'System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest()


    Catch ex As Exception


    Finally
        System.Web.HttpContext.Current.Response.Flush()
        System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest()


        memoryStream.Flush()
        memoryStream.Dispose()

    End Try

End Sub
4

1 に答える 1

2

バグ 103618にいくつかのガイダンスがあり、Chrome が attachment=* の解析でより厳密になったことを文書化しています。これにより、名前に区切り文字が含まれていると、名前が期待どおりにならないことがあります。

また、「インライン」は仕様の一部ではないように見えるため、無視している可能性があります (ただし、これは IE で使用する必要があります)。また、「インライン」と「添付ファイル」があり、インラインを削除して Chrome でテストします。

于 2012-07-11T13:11:03.800 に答える