G
Guest
I have looked everywhere and cannot find a resolution for this. I have read
several post on this forum that allude to similar issues but I have not found
a solution.
I am sending dynamic content to the browser to be opened in Excel. On some
browsers including on the mac it works fine, but in other browsers it sets
the filename to the script instead of to the name specified in the
content-disposition.
I am at my wits end. Here is a snapshot of my code, but I have tried dozens
of permutations. It works on my local machine but not on the server. The
server is running under HTTPS which may be an issue? I have tried without
and with the mime type defined in the IIS on the server. The request is
launched from a javascript window.open and I have tried both relative and
absolute urls.
FYI: this is part of a function and the context is the current httpcontext.
I am doing all this from an HttpHandler with session state enabled.
XslTransform xslt = new XslTransform();
xslt.Load(xslPath);
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.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("Content-Disposition-Type","inline");
//context.Response.AppendHeader("Pragma","cache");
//context.Response.AppendHeader("Expires", "-1");
//context.Response.AppendHeader("Cache-Control","no-store, no-cache,
must-revalidate, post-check=0, pre-check=0");
context.Response.ContentType = "application/vnd.ms-excel";
context.Response.AppendHeader("Content-Disposition",
"inline; " +
"filename=\"" + "Download.xls" + "\"; " +
"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();
several post on this forum that allude to similar issues but I have not found
a solution.
I am sending dynamic content to the browser to be opened in Excel. On some
browsers including on the mac it works fine, but in other browsers it sets
the filename to the script instead of to the name specified in the
content-disposition.
I am at my wits end. Here is a snapshot of my code, but I have tried dozens
of permutations. It works on my local machine but not on the server. The
server is running under HTTPS which may be an issue? I have tried without
and with the mime type defined in the IIS on the server. The request is
launched from a javascript window.open and I have tried both relative and
absolute urls.
FYI: this is part of a function and the context is the current httpcontext.
I am doing all this from an HttpHandler with session state enabled.
XslTransform xslt = new XslTransform();
xslt.Load(xslPath);
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.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("Content-Disposition-Type","inline");
//context.Response.AppendHeader("Pragma","cache");
//context.Response.AppendHeader("Expires", "-1");
//context.Response.AppendHeader("Cache-Control","no-store, no-cache,
must-revalidate, post-check=0, pre-check=0");
context.Response.ContentType = "application/vnd.ms-excel";
context.Response.AppendHeader("Content-Disposition",
"inline; " +
"filename=\"" + "Download.xls" + "\"; " +
"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();