This article mainly introduces the ASP. NET Server sent HTTP headers can not set the content type problem resolution, the article introduced in very detailed, for everyone has a certain reference learning value, the need for friends below to see it together.
Problem found:
Using Npoi to export Excel, the foreground page is still aspx and then the error "failed to receive message from the server" is reported.
Solution:
About the "server cannot set content type after sending HTTP Headers" error:
1. The export component is used Myxls
2. Page with ASPX
3. The main contents of the page are:
<form id= "Form1" runat= "Server" > <asp:scriptmanager id= "Scriptmanager1" runat= "Server" > </asp: scriptmanager> <asp:updatepanel id= "UpdatePanel1" runat= "Server" > <ContentTemplate> < Asp:button runat= "Server" id= "Btnexport" text= "Export to Excel" cssclass= "Btn_common" onclick= " Btnexport_click"/> </ContentTemplate> </asp:UpdatePanel></form>
This cannot be exported and will report the error shown in the header.
The solution is to add "global refresh" capability to Btnexport.
Add the following code to solve the problem
<Triggers> <%--<asp:asyncpostbacktrigger controlid= ""/>--%> <%--local Refresh value Refresh UpdatePanel internal--%> <asp:postbacktrigger controlid= "Btnexport"/> <%--all refresh--%> <%--2016 July 1 Resolve Click Export button Error " The server was unable to set the content type "error after sending HTTP headers"--%></triggers>
Summarize
"Recommended"
1. ASP. NET free Video Tutorials
2. ASP. NET Tutorials
3. Geek Academy ASP. NET Video Tutorial