Codeless Posted June 17, 2003 Posted June 17, 2003 I am trying to force the Open/Download dialog box. This code works, but the first time through it prompts me to save or download the actual .aspx page that I am hyperlinking to. When I choose open, then it gives me the dialog that I am looking for which is to download or open the Torus_grn.jt file. Any ideas on how I can change this so that I only get the dialog about the Torus_grn.jt file? Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim fname As String = "c:\TORUS_GRN.jt" Dim forceDownload As Boolean = True Dim path As Path Dim fullpath = path.GetFullPath(fname) Dim name = path.GetFileName(fullpath) Dim ext = path.GetExtension(fullpath) Dim type As String = "" If Not IsDBNull(ext) Then ext = LCase(ext) End If Select Case ext Case ".htm", ".html" type = "text/HTML" Case ".txt" type = "text/plain" Case ".doc", ".rtf" type = "Application/msword" Case ".csv", ".xls" type = "Application/x-msexcel" Case ".jt" type = "Application/x-avwin" Case Else type = "text/plain" End Select If (forceDownload) Then Response.AppendHeader("content-disposition", _ "attachment; filename=" & name) End If If type <> "" Then Response.ContentType = type End If Response.WriteFile(fullpath) Response.End() End Sub Quote Codeless ...it just goes on and on.
Moderators Robby Posted June 18, 2003 Moderators Posted June 18, 2003 Check if this helps http://www.xtremedotnettalk.com/showthread.php?s=&threadid=69196&highlight=AppendHeader Quote Visit...Bassic Software
Codeless Posted June 27, 2003 Author Posted June 27, 2003 That is exactly what I'm looking for. However I when I try and run it without the database stuff (I just want to point to a file that is on the server). It fails. Can you see why? Private Sub GetDownload() Try Dim sFile As String = "c:\jontest.jpg" Dim fn As Object fn = "c:\logo.bmp" Response.Clear() Response.ContentType = "image/JPG" Response.AppendHeader("Content-Disposition", "filename=" & fn) Dim oImage() As Byte = CType(fn, Byte()) 'Dim oImage() As Byte = GetAttach(nID) Response.BinaryWrite(oImage) Catch Response.Clear() Finally Response.Flush() Response.Close() End Try End Sub I think it has something to do with the object actually being a string object rather than a file object. What do you see O great one? Quote Codeless ...it just goes on and on.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.