Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

IE7 Session and HttpHandler

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jed - 17 Sep 2007 19:04 GMT
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.
Jed - 19 Sep 2007 20:06 GMT
Well to sort of answer my own question...

One resolution to this is to:
1) Add the site to the trusted sites list
2) Reset the security on the trusted sites list to Low
3) Enable local caching of files over HTTPS
4) Enable popups from the site in question

I am fairly convinced that this has something to do with IE7 not sharing
session information between tabs/popups, but I have no idea which setting in
the
security options has an effect on this.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.