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?
Code:
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