473,408 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

PageFlow After HTTPs Write

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
Jul 14 '06 #1
7 2730
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" <Ga******@newsgroups.nospamwrote in message
news:O7*************@TK2MSFTNGP05.phx.gbl...
>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


Jul 14 '06 #2
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
Jul 14 '06 #3
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" <ma******@fitzme.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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" <Ga******@newsgroups.nospamwrote in message
news:O7*************@TK2MSFTNGP05.phx.gbl...
>>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



Jul 15 '06 #4
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]" <pb*******@yahoo.nospammin.comwrote in message
news:54**********************************@microsof t.com...
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

Jul 15 '06 #5
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.

Jul 17 '06 #6
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]" <st*****@online.microsoft.comwrote in message
news:6R**************@TK2MSFTNGXA01.phx.gbl...
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.

Jul 18 '06 #7
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.

Jul 19 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Hasan D | last post by:
I'm new on this httplib and urllib. Actually I dont know what should i use. I want to fill the form in a "https" page , and return the result . I write a test code but always gives errors. I cant...
5
by: Bob Hansen | last post by:
I am using the following code in my default.asp page to redirect the page from HTTP to HTTPS <% if Request.ServerVariables("HTTPS") = "off" Then Response.Redirect("https://" &...
1
by: Ashutosh Bhalerao | last post by:
Hi all, I am trying to write a VB.Net application which communicates over SSL with an IIS server. I have got a temporary certificate from Verisign and installed it on IIS. I am using...
1
by: dave | last post by:
Hello I have one simple form (myform.asp) and it posts to query.asp I had put below code in both file on top of the page to redirect this two pages in https:// so any one can access it thru http...
12
by: Grunff | last post by:
I'm experiencing an interesting problem with carrying a php session over from http to https. Much googling later, I'm still stuck. The application is an online shop, where some user data is...
2
by: Jonathan Wax | last post by:
Hi, I spent the last week looking for an answer to the following question: How can you upload an xml file to an HTTPS server with a specific certificate. Basically doing the same as this html...
1
by: Dees | last post by:
Hi, I am facing a weird problem with HTTPS and Request.Url.AbsoluteUri in my ASP.NET application. Here is the scenario - 1. I have a menu page (Default.aspx), which has the following anchor -...
14
by: david | last post by:
I have developed web forms including login by using ASP.NET via HTTP. Now I want to secure the connection from client to the server via HTTPS. How can I configure the server or something else to...
0
by: shlim | last post by:
Currently I'm using VB.Net to perform a http/https multipart form post to a servlet. I'm able to perform the post using HttpWebrequest via GetRequestStream(). However, the servlet returned me with...
0
by: Raven | last post by:
Hi, I have a problem with a server side redirect from a secure page to a non-secure page (same domain name, same folder) I have added some test code that can display the target URL and that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.