file download in ASP.Net

V

vijay

Hi

I am working on a web application and in ASp.Net using C#. The requirement is to create a csv file on the server and the user should be able to save the file on his machine. I am creating a csv file on the server and throwing the contents of the csv file to the user using Response.BinaryWrite method

It is working fine in every server except my web server (Windows 2003 server) which is in DMZ

The problem I am facing is instead the csv file content, user is getting the html code of the page which he is accessing

I wrote the following code im my aspx.cs fil

long FileSize
FileSize = sourceFile.Length
byte[] getContent = new byte[(int)FileSize]
sourceFile.Read(getContent, 0, (int)sourceFile.Length)
//close the file stream
sourceFile.Close()
//delete the fil
File.Delete(strFilePath)
Response.BinaryWrite(getContent)
Response.End(

How can I get the csv content in the file that is being downloaded by the user

Please help me

Thaks and Regards
Vija
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,147
Latest member
CarenSchni
Top