Good day.
I'm developing a DNN module. One of the functionality, is that of export content to a .csv file, but I have found quite a BIG problem. Here's a sample code:
Response.AddHeader("Content-Disposition", "attachment; filename=file.csv")
Response.ContentType = "text/csv"
Response.WriteFile(Server.MapPath("file.csv"))
Response.End()
note: The code is called during a postback, after the user clicks a button
Almost everything works fine, except that the downloaded file contains the ENTIRE HTML PAGE CONTENT, appended at the end of the file. I noticed this behaviour with any type of file (for examples, .pdf files can be opened and viewed, but if opened with a text-editor, i can see the page html code)
I tried the exact same code outside a dnn module, in a "testfile.aspx" page, and everything works fine.
Is there a way to solve this? Am I missing something?
Any help would be appreciated. If you need more informations please ask.
Thanks in advance,
Alberto.