Markup:
<a href="GenericHandler.ashx?f=Application" title="Application">View Application</a>Generic Handler:
public class GenericHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { string f = context.Request.QueryString.Get("f"); /// /// Option 1: from server location. /// f = @"\\servername\documents\" + f + ".pdf"; /// /// Option 2: from disk location /// f = @"c:\data\documents\" + f + ".pdf"; context.Response.Clear(); context.Response.ContentType = "Application/pdf"; context.Response.WriteFile(f); HttpContext.Current.ApplicationInstance.CompleteRequest(); } public bool IsReusable { get { return false; } } }
No comments:
Post a Comment