avoiding - File download-security warning window when using response.writefile(filepath)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Cindy H

    #1

    avoiding - File download-security warning window when using response.writefile(filepath)

    Hi

    I used the code below to automatically open a pdf file when the user clicks
    on a menu option.
    It works great on local machine, but when I
    uploaded it to hosting site and then tried it,
    I get a 'File download-security warning' window popping up that ask if I
    want to download or open the file.
    It wants to download the aspx page itself , instead of the pdf file.
    I'd would like it to offer to open the pdf file, or avoid this security
    warning window all together.
    I'm thinking it as something to do with the mime content type, but not sure.
    Does anyone know how to do this?

    Thanks,
    CindyH

    'Set the appropriate ContentType.

    Response.Conten tType = "Applicatio n/pdf"

    'Get the physical path to the file.

    Dim FilePath As String = MapPath("Report s\CurrentYear_S hootDates.pdf")

    'Write the file directly to the HTTP content output stream.

    Try

    Response.WriteF ile(FilePath)

    Catch ex As Exception

    Response.Redire ct("DownloadPDF Reader.aspx")

    Response.End()

    End Try

    Response.End()






  • GhostInAK

    #2
    Re: avoiding - File download-security warning window when using response.writef ile(filepath)

    Hello Cindy,

    Well, Cindy, As yer using Server.MapPath( ) the file is obviously servable
    by the web server directly.. just link to the file.

    As for the security dialog, that is a client settings issue.

    -Boo
    Hi
    >
    I used the code below to automatically open a pdf file when the user
    clicks
    on a menu option.
    It works great on local machine, but when I
    uploaded it to hosting site and then tried it,
    I get a 'File download-security warning' window popping up that ask if
    I
    want to download or open the file.
    It wants to download the aspx page itself , instead of the pdf file.
    I'd would like it to offer to open the pdf file, or avoid this
    security
    warning window all together.
    I'm thinking it as something to do with the mime content type, but not
    sure.
    Does anyone know how to do this?
    Thanks,
    CindyH
    'Set the appropriate ContentType.
    >
    Response.Conten tType = "Applicatio n/pdf"
    >
    'Get the physical path to the file.
    >
    Dim FilePath As String = MapPath("Report s\CurrentYear_S hootDates.pdf")
    >
    'Write the file directly to the HTTP content output stream.
    >
    Try
    >
    Response.WriteF ile(FilePath)
    >
    Catch ex As Exception
    >
    Response.Redire ct("DownloadPDF Reader.aspx")
    >
    Response.End()
    >
    End Try
    >
    Response.End()
    >

    Comment

    Working...