After the Asp. Net Server sends an HTTP header, it cannot set the content type.

Source: Internet
Author: User

After the Asp. Net Server sends an HTTP header, it cannot set the content type.

Problems found:

When Excel is exported using Npoi, the foreground page is still aspx, and the error "failed to receive a message from the server" is reported.

Solution:

"The server cannot set the content type after sending the HTTP header" error:

1. The export component uses MyXLS

2. The page uses aspx

3. The main content of the page is:

<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>

If the data cannot be exported, an error in the title is returned.

The solution is to add the global refresh capability to btnExport.

Add the following code to solve the problem.

<Triggers> <% -- <asp: AsyncPostBackTrigger ControlID = ""/> -- %> <% -- refresh the UpdatePanel internal refresh value -- %> <asp: postBackTrigger ControlID = "btnExport"/> <% -- refresh all -- %> <% -- the error "the server cannot set the content type after sending the HTTP header" is reported when you click Export on April 9, July 1, 2016 -- %> </Triggers>

Summary

The above is all the content of this article. I hope the content of this article will help you in your study or work. If you have any questions, please leave a message, thank you for your support.

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.