私のウェブページにはボタンがあります。それをクリックすると、ブラウザにドキュメントを送信したいと思います。
クリックイベントのコードは次のとおりです。
Private Sub btMNCgetTemplate_Click(sender As Object, e As EventArgs) Handles btMNCgetTemplate.Click
Dim MNCid As Integer = Me.cbMNCrequestType.SelectedValue
Dim mncRT As New MinorNetworkChangeTypeOfRequests
Dim MNCrq As New MNCTypeOfRequestItem
MNCrq = mncRT.Find(MNCid)
If MNCrq IsNot Nothing Then
If MNCrq.Form.ToLower.EndsWith(".doc") Or
MNCrq.Form.ToLower.EndsWith(".docx") Then
Response.ContentType = "Application/msword"
Else
Response.ContentType = "Application/x-msexcel"
End If
Response.AppendHeader("Content-Disposition", String.Format("attachment; filename={0}", MNCrq.Form))
Response.TransmitFile(Server.MapPath(String.Format("~/forms/{0}", MNCrq.Form)))
Response.End()
End If
End Sub
MNCrqオブジェクトのFormプロパティには、ファイルの名前があります。
最初はこれは問題なく機能し、ユーザーはファイルの保存ウィンドウを取得しました。しかし、今ではもう機能していません。Chromeでウェブサイトを実行しても何も起こりません。IE9でWebサイトを実行すると、自分のものではないファイルに次のエラーメッセージが表示されます。
Unhandled exception at line 940, column 13 in http://localhost:29226/ScriptResource.axd?
d=DbqlGCg_y1TWNdNykQXSWTqf7VMHZvfOOc8W9SvKy5VJEvrKhkNOK5JNcaIC4d76X42JcWSxljh5epK1GqlRC4_NnfoLlKD1PfZ2-dNg98DHOKlBmICo8PKGlg73PqEQJR5AdM_sf6udu_6Vkp3cg9MicDI1&t=7c776dc1
0x800a139e - Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed.
私はここで何が間違っているのですか?
rg、エリック