Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > PageFlow After HTTPs Write

Reply
Thread Tools

PageFlow After HTTPs Write

 
 
GaryDean
Guest
Posts: n/a
 
      07-14-2006
I have a page that streams PDF documents using the code pasted below. The
Page displays the documents just fine but the user is left with no action
but to hit the back button on the browser which takes him to the page that
redirected to this page where the page load event is not re-executed. It's
just a dead page.

Is there some way I can force a new browser window for this display?

How can I do this display and control the page flow?



---------------------------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
byte[] teststream = (byte[])Session["PDFStream"];
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentType = "Application/PDF";
HttpContext.Current.Response.BinaryWrite(teststrea m);
Response.End();
}
}
--
Regards,
Gary Blakely


 
Reply With Quote
 
 
 
 
Mark Fitzpatrick
Guest
Posts: n/a
 
      07-14-2006
The only thing you could do is have the link itself use the target="top" to
open the PDF page in a new browser window. You can't open a new one through
http or the response object.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"GaryDean" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>I have a page that streams PDF documents using the code pasted below. The
>Page displays the documents just fine but the user is left with no action
>but to hit the back button on the browser which takes him to the page that
>redirected to this page where the page load event is not re-executed. It's
>just a dead page.
>
> Is there some way I can force a new browser window for this display?
>
> How can I do this display and control the page flow?
>
>
>
> ---------------------------------------------------------------------
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!IsPostBack)
> {
> byte[] teststream = (byte[])Session["PDFStream"];
> HttpContext.Current.Response.Clear();
> HttpContext.Current.Response.Buffer = true;
> HttpContext.Current.Response.ContentType = "Application/PDF";
> HttpContext.Current.Response.BinaryWrite(teststrea m);
> Response.End();
> }
> }
> --
> Regards,
> Gary Blakely
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      07-14-2006
Well,
This is an issue that's pretty common. Once you say "Response.End()" that's
basically it my friend.
You could, if you wanted, do this in another browser window and allow the
user to return to the existing one and do something else.
Hope that helps.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




"GaryDean" wrote:

> I have a page that streams PDF documents using the code pasted below. The
> Page displays the documents just fine but the user is left with no action
> but to hit the back button on the browser which takes him to the page that
> redirected to this page where the page load event is not re-executed. It's
> just a dead page.
>
> Is there some way I can force a new browser window for this display?
>
> How can I do this display and control the page flow?
>
>
>
> ---------------------------------------------------------------------
> protected void Page_Load(object sender, EventArgs e)
> {
> if (!IsPostBack)
> {
> byte[] teststream = (byte[])Session["PDFStream"];
> HttpContext.Current.Response.Clear();
> HttpContext.Current.Response.Buffer = true;
> HttpContext.Current.Response.ContentType = "Application/PDF";
> HttpContext.Current.Response.BinaryWrite(teststrea m);
> Response.End();
> }
> }
> --
> Regards,
> Gary Blakely
>
>
>

 
Reply With Quote
 
GaryDean
Guest
Posts: n/a
 
      07-15-2006
If I can't force a new browser page then I am wondering how SQL Server
Reporting Services does it when I code the following:

string myURL = http://localhost/ReportServer/Pages/ReportViewer.aspx? etc
etc....;
Response.Redirect(myURL)"

ReportViewer.aspx is just a page with a ReportViewer control in it but it
renders a new page.

--
Regards,
Gary Blakely
"Peter Bromberg [C# MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Well,
> This is an issue that's pretty common. Once you say "Response.End()"
> that's
> basically it my friend.
> You could, if you wanted, do this in another browser window and allow the
> user to return to the existing one and do something else.
> Hope that helps.
> Peter
>
> --
> Co-founder, Eggheadcafe.com developer portal:
> http://www.eggheadcafe.com
> UnBlog:
> http://petesbloggerama.blogspot.com
>
>
>
>
> "GaryDean" wrote:
>
>> I have a page that streams PDF documents using the code pasted below.
>> The
>> Page displays the documents just fine but the user is left with no action
>> but to hit the back button on the browser which takes him to the page
>> that
>> redirected to this page where the page load event is not re-executed.
>> It's
>> just a dead page.
>>
>> Is there some way I can force a new browser window for this display?
>>
>> How can I do this display and control the page flow?
>>
>>
>>
>> ---------------------------------------------------------------------
>> protected void Page_Load(object sender, EventArgs e)
>> {
>> if (!IsPostBack)
>> {
>> byte[] teststream = (byte[])Session["PDFStream"];
>> HttpContext.Current.Response.Clear();
>> HttpContext.Current.Response.Buffer = true;
>> HttpContext.Current.Response.ContentType = "Application/PDF";
>> HttpContext.Current.Response.BinaryWrite(teststrea m);
>> Response.End();
>> }
>> }
>> --
>> Regards,
>> Gary Blakely
>>
>>
>>



 
Reply With Quote
 
GaryDean
Guest
Posts: n/a
 
      07-15-2006
If I can't force a new browser page then I am wondering how SQL Server
Reporting Services does it when I code the following:

string myURL = http://localhost/ReportServer/Pages/ReportViewer.aspx? etc
etc....;
Response.Redirect(myURL)"

ReportViewer.aspx is just a page with a ReportViewer control in it but it
renders a new page.

--
Regards,
Gary Blakely
"Mark Fitzpatrick" <(E-Mail Removed)> wrote in message
news:%239R09$(E-Mail Removed)...
> The only thing you could do is have the link itself use the target="top"
> to open the PDF page in a new browser window. You can't open a new one
> through http or the response object.
>
> Hope this helps,
> Mark Fitzpatrick
> Microsoft MVP - FrontPage
>
> "GaryDean" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>>I have a page that streams PDF documents using the code pasted below. The
>>Page displays the documents just fine but the user is left with no action
>>but to hit the back button on the browser which takes him to the page that
>>redirected to this page where the page load event is not re-executed.
>>It's just a dead page.
>>
>> Is there some way I can force a new browser window for this display?
>>
>> How can I do this display and control the page flow?
>>
>>
>>
>> ---------------------------------------------------------------------
>> protected void Page_Load(object sender, EventArgs e)
>> {
>> if (!IsPostBack)
>> {
>> byte[] teststream = (byte[])Session["PDFStream"];
>> HttpContext.Current.Response.Clear();
>> HttpContext.Current.Response.Buffer = true;
>> HttpContext.Current.Response.ContentType = "Application/PDF";
>> HttpContext.Current.Response.BinaryWrite(teststrea m);
>> Response.End();
>> }
>> }
>> --
>> Regards,
>> Gary Blakely
>>
>>

>
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-17-2006
Hello Gary,

As for the ASP.NET web page, if you flush out a certain binary document in
the current page response, it will certainly replace the original html page
and the user can not perform further interaction on the original page
unless the user press back button. This limitation is actually due to the
limitation of http response, each http response can only contains content
of a single mine-type. So far, the only way to stream out a binary
document and remain the original page functionable is streaming out the
document in a new separate browser window.

As you mentioned the webform ReportViewer control, I've just performed some
research on it and it is also using the "new browser window" approach. The
"Export" button on the webform reportviewer control is a hyperlink which
point to a location associated with a custom
httphandler("Reserved.ReportViewerControl.axd") , and when we click the
"Export" link, it will open it in a new separate browser window. The
Reserved.ReportViewerControl.axd handler is responsible for streaming out
the certain report (as the requested format) in that new browser windows.

For your scenario, if you do not want to involve an additional httphandler,
you can just add a new page which is dedicated on streaming out document.
And your main page(which will interact with the client user) can use a
hyperlink to link that page(use some querystring paramters to specific
document inforation). How do you think of this?

Please feel free to let me know if you have any other concerns or questions
on this.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to

http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial

response from the community or a Microsoft Support Engineer within 1
business day is

acceptable. Please note that each follow up response may take approximately
2 business days

as the support professional working with you may need further investigation
to reach the

most efficient resolution. The offering is not appropriate for situations
that require

urgent, real-time or phone-based interactions or complex project analysis
and dump analysis

issues. Issues of this nature are best handled working with a dedicated
Microsoft Support

Engineer by contacting Microsoft Customer Support Services (CSS) at

http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
GaryDean
Guest
Posts: n/a
 
      07-18-2006
Steven,
That all makes sense except that when I do
string myURL = http://localhost/ReportServer/Pages/ReportViewer.aspx? etc
etc....;
Response.Redirect(myURL)"
noone is hitting a "Export" button. I'm just doing a Response.Redirect.

Have we somehow found a way to instantiate a new browser window from server
code? I don't know how its working.
--
Regards,
Gary Blakely
"Steven Cheng[MSFT]" <(E-Mail Removed)> wrote in message
news:6Rz7$(E-Mail Removed)...
> Hello Gary,
>
> As for the ASP.NET web page, if you flush out a certain binary document in
> the current page response, it will certainly replace the original html
> page
> and the user can not perform further interaction on the original page
> unless the user press back button. This limitation is actually due to the
> limitation of http response, each http response can only contains content
> of a single mine-type. So far, the only way to stream out a binary
> document and remain the original page functionable is streaming out the
> document in a new separate browser window.
>
> As you mentioned the webform ReportViewer control, I've just performed
> some
> research on it and it is also using the "new browser window" approach. The
> "Export" button on the webform reportviewer control is a hyperlink which
> point to a location associated with a custom
> httphandler("Reserved.ReportViewerControl.axd") , and when we click the
> "Export" link, it will open it in a new separate browser window. The
> Reserved.ReportViewerControl.axd handler is responsible for streaming out
> the certain report (as the requested format) in that new browser windows.
>
> For your scenario, if you do not want to involve an additional
> httphandler,
> you can just add a new page which is dedicated on streaming out document.
> And your main page(which will interact with the client user) can use a
> hyperlink to link that page(use some querystring paramters to specific
> document inforation). How do you think of this?
>
> Please feel free to let me know if you have any other concerns or
> questions
> on this.
>
> Sincerely,
>
> Steven Cheng
>
> Microsoft MSDN Online Support Lead
>
>
>
> ==================================================
>
> Get notification to my posts through email? Please refer to
>
> http://msdn.microsoft.com/subscripti...ult.aspx#notif
> ications.
>
>
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial
>
> response from the community or a Microsoft Support Engineer within 1
> business day is
>
> acceptable. Please note that each follow up response may take
> approximately
> 2 business days
>
> as the support professional working with you may need further
> investigation
> to reach the
>
> most efficient resolution. The offering is not appropriate for situations
> that require
>
> urgent, real-time or phone-based interactions or complex project analysis
> and dump analysis
>
> issues. Issues of this nature are best handled working with a dedicated
> Microsoft Support
>
> Engineer by contacting Microsoft Customer Support Services (CSS) at
>
> http://msdn.microsoft.com/subscripti...t/default.aspx.
>
> ==================================================
>
>
>
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-19-2006
Thanks for your followup Gary,

So I get that your current concern is how to make the page open a new
browser window (to a certain page) in server-side codebehind code, correct?
Based on my experience, the most popular means to open new browser windows
through server-side code is to programmatically register some client-side
scripts (in code behind). And there are several script functions that can
open new browser window, such as

window.open( url) or window.showModelessDialog( url )

The difference between them is "window.open" will open a new page url in a
new normal brower window while "showModelessDialog" will display a web page
dialog(with no address bar and fixed border and size). And currently most
client browsers have some certain popup blocker installed, such blocker
will prevent "window.open" created new windows to work, this is also what
you need to take care(showModelessDialog is not restricted to popup
blocker).

Below is some web article describing the two script functions:
http://www.javascript-coder.com/wind...dow-open.phtml

http://www.webreference.com/js/column90/2.html

And here are some example function on dynamically registering client-script
to open new browser windows to display other pages in ASP.NET page's
server-side code:

===============================
protected void btnOpenNewWindow_Click(object sender, EventArgs e)
{
string url =
"http://localhost/ReportServer/Pages/ReportViewer.aspx?/AdventureWorks+Sampl
e+Reports/Company+Sales";

string script = "window.open('" + url + "');";

Page.ClientScript.RegisterStartupScript(this.GetTy pe(), "open new
window", script, true);
}

protected void btnNewDialog_Click(object sender, EventArgs e)
{
string url =
"http://localhost/ReportServer/Pages/ReportViewer.aspx?/AdventureWorks+Sampl
e+Reports/Company+Sales";

string script = "window.showModelessDialog('" + url + "');";

Page.ClientScript.RegisterStartupScript(this.GetTy pe(), "open new
dialog", script, true);
}
===============================

Hope this helps further.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.

 
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
server side redirect https => https NOT working Axel ASP General 8 04-27-2009 02:02 AM
questions about using workflow to implement a pageflow in ASP.NET. smwikipedia ASP .Net 2 03-26-2008 03:58 PM
https authentication & storing https page in string Naveen Dhanuka Ruby 1 09-19-2007 02:05 PM
open-uri and HTTPS, or net/https with a redirect jotto Ruby 4 10-02-2006 07:26 AM
JSP Workflow FlowControl PageFlow Engine Heiner Kücker Java 1 11-25-2004 11:08 PM



Advertisments