asp.net에서 파일 다운로드를 구현하는 방법asp.net
Answers
http://forums.asp.net/p/1481083/3457332.aspx
string filename = @"Specify the file path in the server over here....";
FileInfo fileInfo = new FileInfo(filename);
if (fileInfo.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.Flush();
Response.TransmitFile(fileInfo.FullName);
Response.End();
}
최신 정보:
초기 코드
Response.AddHeader("Content-Disposition", "inline;attachment; filename=" + fileInfo.Name);
"인라인, 첨부"즉 콘텐츠 처리를위한 두 개의 값을가집니다.
정확히 언제 시작되었는지는 모르지만 Firefox에서는 적절한 파일 이름 만 나타나지 않습니다. 파일 다운로드 상자에 웹 페이지 이름과 확장명 ( pagename.aspx )이 나타납니다. 다운로드 후 실제 이름으로 다시 이름을 바꿉니다. 파일이 성공적으로 열립니다.
이 페이지 는 First Come First Served (첫 번째 Come First Served) 방식으로 운영 됩니다 . 값을 attachment
변경하면 문제가 해결되었습니다.
추신 : 이것이 최선의 관행인지 확실하지 않지만 문제가 해결되었습니다.
'Knowledge' 카테고리의 다른 글
[ASP.NET] [EPPlus] Create/Read/Edit Advance Excel 2007/2010 (0) | 2018.05.01 |
---|---|
[ASP.NET] [EPPlus] Create Excel Files in C# (0) | 2018.05.01 |
[.NET] SFTP (0) | 2018.04.27 |
Using AWS KMS Master Keys with the AmazonS3EncryptionClient in the AWS SDK for .NET (0) | 2018.04.27 |
AWS KMS를 이용한 암호화 API 구축하기 (0) | 2018.04.27 |