我在asp.net网站上有一个按钮,当我将某些值指向此错误时,会下载Excel文件。
我的代码背后如下
Protected Sub Button4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button4.Click
Response.Clear()
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls")
Response.Charset = ""
Response.ContentType = "application/vnd.xls"
Dim stringWrite As New System.IO.StringWriter()
Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(stringWrite)
GridView6.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.[End]()
End Sub
aspx中的按钮如下:
<asp:Button ID="Button4" runat="server" Text="Extract RTD Raw Data" nclick="Button4_Click"
BackColor="#FF9966" CssClass="myButton" Font-Bold="True"
Font-Italic="True" />
我正在获得此堆栈跟踪。
[OutOfMemoryException:类型的异常&#39; System.OutOfMemoryException&#39;被扔了。]
System.Web.Util.HttpEncoder.UrlDecode(Byte [] bytes,Int32 offset, Int32计数,编码编码)+76
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte [] bytes, 编码编码)+164
System.Web.HttpRequest.FillInFormCollection()+ 77 [HttpException (0x80004005):URL编码的表单数据无效。]
System.Web.HttpRequest.FillInFormCollection()+130
System.Web.HttpRequest.EnsureForm()+ 69
System.Web.HttpRequest.get_Form()+13
System.Web.HttpRequest.get_HasForm()+ 9800635
System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +95 System.Web.UI.Page.DeterminePostBackMode()+69 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) 220
答案 0 :(得分:0)
在Web.config文件中插入以下标记<machineKey validationKey="929DF4BCF13739428C8C765842BD122C653C28F688D399F216942E5438AA880B4A793C0772A51660FDA9A69B079AB3B0ADFCFC14941F5BBD673BC72E9804DF44" decryptionKey="0B4443E8C132884733E8B26587FFCE50562CF8CF9980BAD4813A95D54A7A369B" validation="SHA1" decryption="AES" />
后,没有错误。