using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.IO; public partial class open_pdf : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btn_open_Click(object sender, EventArgs e) { string open_path = Server.MapPath("~/upload/IPM.pdf"); WebClient client = new WebClient(); Byte[] buffer = client.DownloadData(open_path); Response.ContentType = "application/pdf"; Response.AddHeader("content-length", buffer.Length.ToString()); Response.BinaryWrite(buffer); Response.Flush(); Response.End(); } }
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="open_pdf.aspx.cs" Inherits="open_pdf" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="btn_open" runat="server" OnClick="btn_open_Click" Text="open pdf" /> </div> </form> </body> </html>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)