2015-02-04 5 views
0

업로드 폴더에 .doc, .docx, .pdf, .xls 등 다른 파일이 있습니다. 이미지를 클릭 할 때 파일을 다운로드하고 싶습니다. 나는 제대로 통과 JQuery와 값에서 제네릭 처리기 HTTP를하는 호출하지만다운로드 파일을 http 핸들러에서 사용자 정의 이름

   HttpContext.Current.Response.ClearHeaders(); 
       HttpContext.Current.Response.ClearContent(); 
       HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name); 
       HttpContext.Current.Response.AppendHeader("Content-Length", fileInfo.Length.ToString()); 
       HttpContext.Current.Response.ContentType = "application/octet-stream"; 
       HttpContext.Current.Response.TransmitFile(fileInfo.FullName); 
       HttpContext.Current.Response.Flush(); 

답변

0

이 같은 시도 작동하지 오전 :

Response.Clear(); 
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileInfo.Name); 
Response.AddHeader("Content-Length", fileInfo.Length.ToString()); 
Response.ContentType = "application/octet-stream"; 
Response.WriteFile(fileInfo.FullName); 
Response.End(); 

그것은 작동합니다을!