Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1021155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:16:07+00:00 2026-05-16T11:16:07+00:00

Using this lovely example I am getting some funky results. What I have is:

  • 0

Using this lovely example I am getting some funky results. What I have is:

Protected Sub btnCSV_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCSV.Click

    Response.Clear()
    Response.Buffer = True
    Response.ContentType = "text/csv"
    Response.AppendHeader("Content-Disposition", "inline; filename=" + FileName + ".csv")

    CsvHelper.ProduceCSV(dt, Response.Output, True)

End Sub

But what is happening is that the csv file contains the html output from the page as well as the csv data from the CsvHelper. What gives?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:16:08+00:00Added an answer on May 16, 2026 at 11:16 am

    When btnCSV is clicked your event-handler method sends the CSV data to the response buffer. But once the method finishes executing, the remainder of the page lifecycle continues, sending the normal page markup to the response buffer. This is why you have HTML appended to the CSV.

    To prevent this you’ll need to end the request as soon as the CSV data has been generated. You’ll probably want to call Application.CompleteRequest, or similar, following your ProduceCSV call.

    Edit…

    After taking a look at the documentation, rather than relying on my memory, it seems that the HttpApplication object isn’t exposed within a standard ASP.NET page, in which case you’ll probably need to use Response.End instead. Not ideal, but it’ll do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created some lovely reports using SQL Server Business Intelligence Development creating a
I have implented some lovely forms authentication in ASP.NET MVC 3, this has been
Using this page, http://developer.android.com/sdk/compatibility-library.html , I have installed the Android Support Package, added a
Using this file as source, I have a situation where I need to retrieve
I'm using Thauber's lovely Django schedule app , but have run into a problem:
So I have this grid. It's a very nice grid. Lovely, really. Except when
I have a lovely AppleScript droplet which performs OCR of a PDF file using
I have a whole bunch of files with filenames using our lovely Swedish letters
I have a string! NSString *myString=[NSString stringWithFormat:@This is my lovely string]; What I want
So, I'm using this lovely image swap fellow: jQuery Image Swap Gallery You can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.