G
Guest
I have an app I wrote in ASP.NET 1.1. It has a reporting feature which
formats results as an html table and returns it as an "Excel" file. It works
fine in IE6 and Firefox, but it doesn't work in IE7. I originally had
trouble because IE6 does not cache HTTPS files by default, but after I
changed that setting IE6 worked fine. Now even with that setting correctly
indicated, IE7 doesn't work. Here is the code that generates the Excel
response. The code is executed in an HttpHandler.
//Static method that formats the response.
public static void RenderReport(
string fileName,
XmlDocument xmlDocument,
string xslPath,
XsltArgumentList xargs
)
{
HttpContext context = HttpContext.Current;
XslTransform xslt = new XslTransform();
xslt.Load(xslPath);
if (xargs == null)
{
xargs = new XsltArgumentList();
}
System.IO.MemoryStream stream = new System.IO.MemoryStream();
xslt.Transform(xmlDocument, xargs, stream, new XmlUrlResolver());
context.Response.Buffer = true;
context.Response.Clear();
context.Response.ClearContent();
context.Response.ClearHeaders();
context.Response.Cookies.Clear();
context.Response.Cache.SetCacheability(HttpCacheability.Private);
context.Response.CacheControl = "private";
context.Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
//string.Empty;
context.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
context.Response.AppendHeader("Content-Length", stream.Length.ToString());
context.Response.AppendHeader("Pragma","cache");
context.Response.AppendHeader("Expires", "60");
if (xslPath.IndexOf("Excel") > -1)
{
context.Response.ContentType = "application/vnd.ms-excel";
}
else if (xslPath.IndexOf("Word") > -1)
{
context.Response.ContentType = "text/vnd.ms-word";
}
else
{
context.Response.ContentType = "text/html";
}
context.Response.AppendHeader("Content-Disposition",
"inline; " +
"filename=\"" + fileName + "\"; " +
"size=" + stream.Length.ToString() + "; " +
"creation-date=" + DateTime.Now.ToString("R") + "; " +
"modification-date=" + DateTime.Now.ToString("R") + "; " +
"read-date=" + DateTime.Now.ToString("R"));
context.Response.BinaryWrite(stream.ToArray());
stream.Close();
context.Response.Flush();
context.Response.Close();
stream = null;
context.Response.End();
}
This is the method from the HttpHandler:
private void RenderReport(string fileName)
{
if (Context.Session["ReportXml"] == null)
{
//This is where IE7 always ends up.
Context.Response.Write("The content of the report could not be loaded.
Close this window and try again.");
Context.Response.End();
}
else
{
XmlDocument xmlDoc = (XmlDocument)Context.Session["ReportXml"];
string xslPath = (string)Context.Session["ReportXslPath"];
XsltArgumentList xslArgs =
(XsltArgumentList)Context.Session["ReportXslArgs"];
Context.Session["ReportXml"] = null;
Context.Session["ReportXslPath"] = null;
Context.Session["ReportXslArgs"] = null;
Utility.Report.RenderReport(fileName, xmlDoc, xslPath, xslArgs);
}
}
//Code from the page
public void RenderReport(string xslPath)
{
xslPath = Server.MapPath(ResolveUrl(xslPath));
XmlDocument xmlDoc = GetReportXml();
XsltArgumentList xslArgs = new XsltArgumentList();
//2004-08-13T00:07:31.933
xslArgs.AddParam("CreatedDate", string.Empty,
DateTime.Now.ToShortDateString());
xslArgs.AddParam("DisplayMode", string.Empty, "Detail");
xslArgs.AddParam("RootUrl", string.Empty, this.LocalContext.CurrentHost +
ResolveUrl("~/"));
Session["ReportXml"] = xmlDoc;
Session["ReportXslPath"] = xslPath;
Session["ReportXslArgs"] = xslArgs;
string popUpScript =
Utility.Report.CreateReportPopUpScript(this.LocalContext.CurrentHost +
ResolveUrl("~/"), xslPath);
this.Page.RegisterStartupScript("PopupScript", popUpScript);
}
Basically, the page puts the data in the session and initiates a pop-up when
the page loads. The pop-up calls the HttpHandler which grabs the data out of
the Session, Transforms it and then sends it back. IE7 always lands in the
(Session["ReportXml"] == null) == true statement of the HttpHandler.
Any help or insight on how to get IE7 to support this would be great.
Thanks in advance.
formats results as an html table and returns it as an "Excel" file. It works
fine in IE6 and Firefox, but it doesn't work in IE7. I originally had
trouble because IE6 does not cache HTTPS files by default, but after I
changed that setting IE6 worked fine. Now even with that setting correctly
indicated, IE7 doesn't work. Here is the code that generates the Excel
response. The code is executed in an HttpHandler.
//Static method that formats the response.
public static void RenderReport(
string fileName,
XmlDocument xmlDocument,
string xslPath,
XsltArgumentList xargs
)
{
HttpContext context = HttpContext.Current;
XslTransform xslt = new XslTransform();
xslt.Load(xslPath);
if (xargs == null)
{
xargs = new XsltArgumentList();
}
System.IO.MemoryStream stream = new System.IO.MemoryStream();
xslt.Transform(xmlDocument, xargs, stream, new XmlUrlResolver());
context.Response.Buffer = true;
context.Response.Clear();
context.Response.ClearContent();
context.Response.ClearHeaders();
context.Response.Cookies.Clear();
context.Response.Cache.SetCacheability(HttpCacheability.Private);
context.Response.CacheControl = "private";
context.Response.Charset = System.Text.UTF8Encoding.UTF8.WebName;
//string.Empty;
context.Response.ContentEncoding = System.Text.UTF8Encoding.UTF8;
context.Response.AppendHeader("Content-Length", stream.Length.ToString());
context.Response.AppendHeader("Pragma","cache");
context.Response.AppendHeader("Expires", "60");
if (xslPath.IndexOf("Excel") > -1)
{
context.Response.ContentType = "application/vnd.ms-excel";
}
else if (xslPath.IndexOf("Word") > -1)
{
context.Response.ContentType = "text/vnd.ms-word";
}
else
{
context.Response.ContentType = "text/html";
}
context.Response.AppendHeader("Content-Disposition",
"inline; " +
"filename=\"" + fileName + "\"; " +
"size=" + stream.Length.ToString() + "; " +
"creation-date=" + DateTime.Now.ToString("R") + "; " +
"modification-date=" + DateTime.Now.ToString("R") + "; " +
"read-date=" + DateTime.Now.ToString("R"));
context.Response.BinaryWrite(stream.ToArray());
stream.Close();
context.Response.Flush();
context.Response.Close();
stream = null;
context.Response.End();
}
This is the method from the HttpHandler:
private void RenderReport(string fileName)
{
if (Context.Session["ReportXml"] == null)
{
//This is where IE7 always ends up.
Context.Response.Write("The content of the report could not be loaded.
Close this window and try again.");
Context.Response.End();
}
else
{
XmlDocument xmlDoc = (XmlDocument)Context.Session["ReportXml"];
string xslPath = (string)Context.Session["ReportXslPath"];
XsltArgumentList xslArgs =
(XsltArgumentList)Context.Session["ReportXslArgs"];
Context.Session["ReportXml"] = null;
Context.Session["ReportXslPath"] = null;
Context.Session["ReportXslArgs"] = null;
Utility.Report.RenderReport(fileName, xmlDoc, xslPath, xslArgs);
}
}
//Code from the page
public void RenderReport(string xslPath)
{
xslPath = Server.MapPath(ResolveUrl(xslPath));
XmlDocument xmlDoc = GetReportXml();
XsltArgumentList xslArgs = new XsltArgumentList();
//2004-08-13T00:07:31.933
xslArgs.AddParam("CreatedDate", string.Empty,
DateTime.Now.ToShortDateString());
xslArgs.AddParam("DisplayMode", string.Empty, "Detail");
xslArgs.AddParam("RootUrl", string.Empty, this.LocalContext.CurrentHost +
ResolveUrl("~/"));
Session["ReportXml"] = xmlDoc;
Session["ReportXslPath"] = xslPath;
Session["ReportXslArgs"] = xslArgs;
string popUpScript =
Utility.Report.CreateReportPopUpScript(this.LocalContext.CurrentHost +
ResolveUrl("~/"), xslPath);
this.Page.RegisterStartupScript("PopupScript", popUpScript);
}
Basically, the page puts the data in the session and initiates a pop-up when
the page loads. The pop-up calls the HttpHandler which grabs the data out of
the Session, Transforms it and then sends it back. IE7 always lands in the
(Session["ReportXml"] == null) == true statement of the HttpHandler.
Any help or insight on how to get IE7 to support this would be great.
Thanks in advance.