Hi,
I do that in asp.net mvc and it works fine on IE6, IE7 and Firefox 3.5.3
Here is my code :
Html code :
<div id="ProductDetailsModal">
<iframe src="<%= Url.Content("~/GetPdf.axd?id=" + ViewData["ProductId"] + "&type=" + ViewData["ContentType"]) %>" width="100%" height="98%"></iframe>
</div>
And here the HttpHandler Code :
public void ProcessRequest(HttpContext context)
{
if (!String.IsNullOrEmpty(context.Request.Params["Id"]) && !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 && !String.IsNullOrEmpty(type))
{
var pc = productBusiness.GetProductContent(username, password, id, type, string.Empty);
if (!String.IsNullOrEmpty(pc.Name) && !String.IsNullOrEmpty(pc.Extension) && 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();
}
}
}
Hope this helps.