2009-11-28 3 views
0

데이터베이스에서 pdf 파일을 가져 와서 링크를 사용하여 pdf 파일을 여는 "href"태그에 연결했습니다. 이제 pdf 파일을 열기 전에 열기/저장 대화 상자를 제공하려고합니다. - 자바 스크립트에서 브라우저에서이 동작을 얻기 위해 C# .NET을 사용하여 내용 - 처리 헤더를 설정해야DB-asp.net에서 pdf 파일을 검색하는 링크

답변

2

(사용하여 는 자바 스크립트를 호출하는 ""태그에 이벤트를 온 클릭).

더 많은 정보를 원하시면

How do I prompt a "Save As" dialog for an accepted mime type?

Downloading a File with a Save As Dialog in ASP.NET

Response.Clear(); 
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); 
Response.AddHeader("Content-Length", targetFile.Length.ToString); 
Response.ContentType = "application/pdf"; 
Response.WriteFile(targetFile.FullName); 
+0

일을이 읽기, 여기에 SO 게시물에 관련된 또 다른입니다 : http://stackoverflow.com/questions/1024910/allow-user-to-download-from-m y-site-through-response-writefile –

관련 문제