Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' ページを初期化するユーザー コードをここに挿入します。
If Not Page.IsPostBack Then
Dim FilePath As String = Session("FilePath").ToString()
If FilePath Is Nothing Then
Response.Write("<h1>Server is unusable!</h1>")
Else
Try
Dim fs As System.IO.FileStream = System.IO.File.OpenRead(FilePath)
Dim FileData(fs.Length) As Byte
fs.Read(FileData, 0, CType(fs.Length, Integer))
fs.Close()
Session.Clear()
Response.ClearHeaders()
Response.AddHeader("Content-Type", "application/vnd.ms-excel")
Response.AddHeader("Content-Disposition", "inline;filename=" + FilePath)
Response.AddHeader("Content-Length", FileData.Length.ToString())
Response.BinaryWrite(FileData)
Catch ex As Exception
Response.Write("<h1>Server is unusable!</h1>")
End Try
Response.End()
End If
End If
End Sub