Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Server.Transfer working for IIS 5.1 but not for IIS 6.0

Reply
Thread Tools

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

 
 
=?Utf-8?B?VmljdG9yIFNvbmc=?=
Guest
Posts: n/a
 
      05-31-2004
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

 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      06-01-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HttpWebRequest Post with ClientCertificates working in Debug and VS, but not working in IIS calebmeii@gmail.com ASP .Net 0 06-29-2007 04:55 PM
Multiple COM objects running on IIS 6.0, but not on IIS 5.0 =?Utf-8?B?Ymc=?= ASP .Net 0 12-30-2004 05:55 PM
ASP.NET application works in IIS PWS, but not in remote IIS. Matthew Louden ASP .Net 3 11-07-2003 09:58 PM
SQL Server connection string works with IIS 5.1 but not IIS 6 in ASP.NET John Kennedy ASP .Net Web Services 5 08-14-2003 12:15 AM
SQL Server connection string works with IIS 5.1 but not IIS 6 in ASP.NET John Kennedy ASP .Net Security 5 08-14-2003 12:15 AM



Advertisments