468,249 Members | 1,431 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,249 developers. It's quick & easy.

Server.Transfer working for IIS 5.1 but not for IIS 6.0

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((QSSessionVariable Name == 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=User Download&DefaultFileName=JEPosting.csv")
Any help is really appreciated
Victo

Nov 18 '05 #1
1 3302
The ASP.NET Server.Transfer method is different than that of ASP
as it includes an overload related to the ViewState to identify one of
several considerations. You'll need to delve into documentation [1]
and while there study the Page class looking at the Context property
that provides access to the HttpContext object for the current request,
i.e. HttpContext.Handler and HttpContext.Items.

My MCAD training guide states we can not pass a QueryString in
the URL with the Server.Transfer method which I remain confised
about myself as this little test harness [2] allowed me to pass a Query
String from PageTransfer_Sender.aspx to PageTransfer_Target.aspx.

--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET csgallagher@ REMOVETHISTEXT metromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

[1]
http://msdn.microsoft.com/library/de...nsferTopic.asp

[2] string qs;

private void Page_Load(object sender, System.EventArgs e)
{
qs = "?qs=" + txtQueryString.Text;
}
....
private void btnTransfer_Click(object sender, System.EventArgs e)
{
Server.Transfer("PageTransfer_Target.aspx" + qs);
}
"Victor Song" <an*******@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
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.htm 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 parameters
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();
}
else
System.Diagnostics.Debug.Assert((OutputStream == null || OutputStream.Length == 0),"Output stream is empty"); }
else
System.Diagnostics.Debug.Assert((QSSessionVariable Name == 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 page Session.Add("UserDownload", FileStream);
Server.Transfer("Download.aspx?SessionVarName=User Download&DefaultFileNa
me=JEPosting.csv"); }
Any help is really appreciated,
Victor

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Justin | last post: by
5 posts views Thread by Paul de Goede | last post: by
5 posts views Thread by Nedu N | last post: by
8 posts views Thread by Cathie | last post: by
4 posts views Thread by john | last post: by
4 posts views Thread by Stan | last post: by
18 posts views Thread by UJ | last post: by
8 posts views Thread by p3t3r | last post: by
6 posts views Thread by n# | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.