I have a button on asp.net website that downloads the Excel file when I put certain values it points this error.
My code behind is as follows
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
The button in aspx is as follows:
<asp:Button ID="Button4" runat="server" Text="Extract RTD Raw Data" nclick="Button4_Click"
BackColor="#FF9966" CssClass="myButton" Font-Bold="True"
Font-Italic="True" />
I am getting this stack trace.
[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.]
System.Web.Util.HttpEncoder.UrlDecode(Byte[] bytes, Int32 offset, Int32 count, Encoding encoding) +76
System.Web.HttpValueCollection.FillFromEncodedBytes(Byte[] bytes, Encoding encoding) +164
System.Web.HttpRequest.FillInFormCollection() +77 [HttpException (0x80004005): The URL-encoded form data is not valid.]
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