开发者

.csv file opens as HTML document

开发者 https://www.devze.com 2023-02-14 16:46 出处:网络
All, In my application i allow users to download a csv filefrom the App.When a user clicks on the Download file link , they see the Download file dialog box. My problem is that some o f the files ope

All,

In my application i allow users to download a csv file from the App. When a user clicks on the Download file link , they see the Download file dialog box. My problem is that some o f the files opens as an HTML document.This happens intermittently.This is the code am using.Can anyone please help?

Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/octet-stream"; 
Response.AppendHeade开发者_StackOverflowr("Content-Disposition"
  , "attachment; filename=" + sf.FileName);
Response.OutputStream.Write(sf.Data, 0, sf.Data.Length);
Response.Flush();
Response.Close();

I tried Response.End() insted of Response.Flush(); but didnt help.

Any help would be greatly appreciated

THanks

RJ


text/csv is more appropriate.

see: Response Content type as CSV

0

精彩评论

暂无评论...
验证码 换一张
取 消