G
Guest
Hi
We are trying to stream a file using server.transfer rather than response.redirect. We have it working for IIS 5.0 but IIS 6.0 refusing to let us transfer the file. If we do the less efficient prompt/response technique to the browser both work fine.
We found this article that was only slightly appicable (ms-help://MS.MSDNQTR.2004APR.1033/enu_kbiis/iis/326965.ht
kb 326965 ) but since csv is already a defined mime type this shouldn't be an issue
Is there some type of security setting or some other trick to get it working with IIS 6.0?
Here are some code snippets
private void Page_Load(object sender, EventArgs e
//get query string parameter
string QSSessionVariableName = Request.QueryString["SessionVarName"]
string DefaultFileName = Request.QueryString["DefaultFileName"]
if (DefaultFileName.Length == 0) DefaultFileName = "output.csv"
if (QSSessionVariableName.Length > 0
string OutputStream = (string) Session[QSSessionVariableName]
if (OutputStream.Length > 0
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + DefaultFileName)
//Response.AddHeader("Content-Length", OutputStream.Length.ToString())
Response.ContentType = "application/x-csv"
Response.Write(OutputStream)
Response.Flush()
Response.End()
els
System.Diagnostics.Debug.Assert((OutputStream == null || OutputStream.Length == 0),"Output stream is empty")
els
System.Diagnostics.Debug.Assert((QSSessionVariableName == null | QSSessionVariableName.Length == 0),"Stream Variable Name is not passed from QueryString")
rather than using something like ...
if (FileStream.Length > 0
//store stream in session variable and redirect to download pag
Session.Add("UserDownload", FileStream)
Server.Transfer("Download.aspx?SessionVarName=UserDownload&DefaultFileName=JEPosting.csv")
Any help is really appreciated
Victo
We are trying to stream a file using server.transfer rather than response.redirect. We have it working for IIS 5.0 but IIS 6.0 refusing to let us transfer the file. If we do the less efficient prompt/response technique to the browser both work fine.
We found this article that was only slightly appicable (ms-help://MS.MSDNQTR.2004APR.1033/enu_kbiis/iis/326965.ht
kb 326965 ) but since csv is already a defined mime type this shouldn't be an issue
Is there some type of security setting or some other trick to get it working with IIS 6.0?
Here are some code snippets
private void Page_Load(object sender, EventArgs e
//get query string parameter
string QSSessionVariableName = Request.QueryString["SessionVarName"]
string DefaultFileName = Request.QueryString["DefaultFileName"]
if (DefaultFileName.Length == 0) DefaultFileName = "output.csv"
if (QSSessionVariableName.Length > 0
string OutputStream = (string) Session[QSSessionVariableName]
if (OutputStream.Length > 0
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment; filename=" + DefaultFileName)
//Response.AddHeader("Content-Length", OutputStream.Length.ToString())
Response.ContentType = "application/x-csv"
Response.Write(OutputStream)
Response.Flush()
Response.End()
els
System.Diagnostics.Debug.Assert((OutputStream == null || OutputStream.Length == 0),"Output stream is empty")
els
System.Diagnostics.Debug.Assert((QSSessionVariableName == null | QSSessionVariableName.Length == 0),"Stream Variable Name is not passed from QueryString")
rather than using something like ...
if (FileStream.Length > 0
//store stream in session variable and redirect to download pag
Session.Add("UserDownload", FileStream)
Server.Transfer("Download.aspx?SessionVarName=UserDownload&DefaultFileName=JEPosting.csv")
Any help is really appreciated
Victo