By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,674 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

file download in asp.net

P: n/a
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

Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
it depends on how you want to show it on the browser.
say if you want show the data in excel sheet set
Response.ContentType = "application/vnd.ms-excel";

Av.

"vijay" <an*******@discussions.microsoft.com> wrote in message
news:1F**********************************@microsof t.com...
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 file

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 file
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,
Vijay


Nov 18 '05 #2

P: n/a
?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ??????.??????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ?????????????????????????????????????????????????? ????????????????????????????????????????????????
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.