Solve. NET Server cannot set content type after sending HTTP

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.