[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

ASP display page, wait, redirect

I am trying to make this page show up, then wait before redirecting.  The redirect code works good but the page does not display.  I tried putting all the ASP code before the <body><img...tags and after.  The function of the page is just to add info into tables into the database.  I wanted an image to display that basically illustrates to the user what is happening.

.........code
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Clear

'Wait, then logout
strInNow = Time
      While Time < DateAdd("S", 10, strInNow)
      Wend

Response.Redirect "logout.asp"
0
Insomniac_PhD
Asked:
Insomniac_PhD
  • 5
  • 2
  • 2
  • +2
2 Solutions
 
muzzy2003Commented:
Try putting:

Call Response.Flush()

just before you do the time consuming stuff. It sends all pending output to the client immediately while you do the time consuming stuff. You won't then be able to use Response.Redirect, though. You'd have to finally send some JavaScript like this:

<script language="javascript">
window.location.href = 'logout.asp';
</script>

to achieve the redirection.
0
 
AgentSmith007Commented:
<script language="javascript">
function fRedirect(){
   location.replace("http://www.intel.com");
}
//5000 = 5 second wait
self.setTimeout('fRedirect()', 5000)
</script>
0
 
muzzy2003Commented:
I read the question to imply that the image is displayed while some server side processing goes on. If this is not the case, then Agent Smith's answer works fine. If it is, then perhaps you might want to add his/her timeout to my bit of JavaScript to ensure that the image is visible for long enough. For example, if the processing only takes 0.5 seconds, then the user won't get much of a chance to view the image. Combining the two gives a third solution that may also be the best for your needs.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
shankarkrupaCommented:
Try this...?

<%
.........code
Set rs = Nothing
conn.Close
Set conn = Nothing
%>

Loggin off...Please wait.

<img src="logout.jpg">

<script language="javascript">
function logout()
{
document.location.href="logout.asp"
}
setTimeout('logout()',5000)
</script>
0
 
shankarkrupaCommented:
Oh, sorry. Didn't see your replies. basically same. Sorry Muzzy & Agent Smith.

Krupa
0
 
hujiCommented:
Well there is a way if you really want to do it with only ASP. Your response text is not shown, because it is not sent to user yet. So you can force it to be sent using response.Flush . Also you have to set response.buffer to TRUE in the FIRST line of your code:

<% response.buffer = true %>
...
<%
.........code
Set rs = Nothing
conn.Close
Set conn = Nothing
Response.Flush                 'Not response.clear

'Wait, then logout
strInNow = Time
      While Time < DateAdd("S", 10, strInNow)
      Wend

Response.Redirect "logout.asp"

....


%>




Wish I can help
Huji
0
 
muzzy2003Commented:
Er ... isn't Response.Flush what I suggested 40 minutes ago huji?
0
 
muzzy2003Commented:
Also, you can't use Response.Redirect after Response.Flush, as the HTTP headers will already have been written, and one of these is used to perform the redirection.
0
 
hujiCommented:
Yes muzzy2003! I sent the code knowing that. I just wanted to help the author to reach to a better understanding, with a sample code. The idea is yours.
Huji
PS: We are basically here to help, not to harvest points! I sent that just for this reason. I hope you have a same opinion.
0
 
muzzy2003Commented:
One other point: Response.Buffer = True is not necessary - if it was currently set to False then the output would be sent directly to the client anyway, and the question wouldn't have arisen. Setting Response.Buffer = False at the top would in fact be another alternative to Response.Flush.
0
 
Insomniac_PhDAuthor Commented:
OK, I am giving your solutions a try... give me a few moments here.  Thanks.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 5
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now