Monday, August 23, 2010

Trouble creating csv for download

Programmer Question

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?



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails