Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I do that in asp.net mvc and it works fine on IE6, IE7 and Firefox 3.5.3</p> <p>Here is my code :</p> <p>Html code :</p> <pre><code>&lt;div id="ProductDetailsModal"&gt; &lt;iframe src="&lt;%= Url.Content("~/GetPdf.axd?id=" + ViewData["ProductId"] + "&amp;type=" + ViewData["ContentType"]) %&gt;" width="100%" height="98%"&gt;&lt;/iframe&gt; &lt;/div&gt; </code></pre> <p>And here the HttpHandler Code :</p> <pre><code>public void ProcessRequest(HttpContext context) { if (!String.IsNullOrEmpty(context.Request.Params["Id"]) &amp;&amp; !String.IsNullOrEmpty(context.Request.Params["Type"])) { IProductBusiness productBusiness = new ProductBusiness(); var username = context.Session["Username"] as String; var password = context.Session["Password"] as String; var id = context.Request.Params["Id"].ToInt(); var type = context.Request.Params["Type"]; if (id != 0 &amp;&amp; !String.IsNullOrEmpty(type)) { var pc = productBusiness.GetProductContent(username, password, id, type, string.Empty); if (!String.IsNullOrEmpty(pc.Name) &amp;&amp; !String.IsNullOrEmpty(pc.Extension) &amp;&amp; pc.Extension.ToLower() == "pdf") { var len = pc.File.Length; byte[] output = Convert.FromBase64String(pc.File); context.Response.Clear(); context.Response.ContentType = "application/pdf"; context.Response.AddHeader("Content-Disposition", String.Format("FileName=\"{0}\"", pc.Name)); context.Response.AddHeader("content-length", output.Length.ToString()); context.Response.Cache.SetCacheability(HttpCacheability.Private); context.Response.Expires = -1; context.Response.Buffer = true; context.Response.BinaryWrite(output); context.Response.End(); } else { context.Response.Write("Erreur lors du chargement du fichier."); } context.Response.Clear(); } } } </code></pre> <p>Hope this helps.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload