Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Server.Transfer working for IIS 5.1 but not for IIS 6.0 (http://www.velocityreviews.com/forums/t79434-server-transfer-working-for-iis-5-1-but-not-for-iis-6-0-a.html)

=?Utf-8?B?VmljdG9yIFNvbmc=?= 05-31-2004 10:41 PM

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


clintonG 06-01-2004 12:36 AM

Re: Server.Transfer working for IIS 5.1 but not for IIS 6.0
 
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" <anonymous@discussions.microsoft.com> wrote in message
news:1DE7D849-C8F5-47E9-B900-59CCB387B5D3@microsoft.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
>





All times are GMT. The time now is 05:40 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.