Solved

A timer in an asp.net before redirecting you to another page

Posted on 2010-11-14
9
646 Views
Last Modified: 2012-05-10
I want to add a timer to an asp.net page.  After the timer runs out, I want the website to be redirected to another.  How do I do that?  I would want the page to be redirected after about 10 seconds.
0
Comment
Question by:VBBRett
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 21

Expert Comment

by:Alfred1
ID: 34134004
Try putting this in the head tag of your ASP.NET page source.  Example redirect after 20 seconds.

<head>
<META HTTP-EQUIV="refresh" CONTENT="20;URL=http://test123.com/default.aspx; text/html; charset=us-ascii;">
</head>
0
 
LVL 2

Accepted Solution

by:
AarthiPrabakaran earned 250 total points
ID: 34134029
protected override void OnStart(string[] args)
        {
             //TODO: Add code here to start your service.
            businessthreadStarter = new Thread(new ThreadStart(this.BusinessFacadeThreadStart));
            businessthreadStarter.Start();

            timer = new System.Timers.Timer();

            timer.Interval = Convert.ToDouble(ConfigurationManager.AppSettings["TimerValue"].ToString());

            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);

            timer.Enabled = true;

            timer.Start();
}

 private void timer_Elapsed(object sender,
              System.Timers.ElapsedEventArgs e)
        {
           Response.redirect("home.aspx");
        }
0
 

Author Comment

by:VBBRett
ID: 34134061
You wouldn't happen to know how to do this in VB, would ya?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 21

Expert Comment

by:Alfred1
ID: 34134075
0
 

Author Comment

by:VBBRett
ID: 34134106
Can you make it very simple please?  I wouldn't be referencing any values in the web.config file.  Thanks!
0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34134131
Have you tried the meta tag?  For 10 seconds.

<head>
<META HTTP-EQUIV="refresh" CONTENT="10;URL=http://test123.com/default.aspx; text/html; charset=us-ascii;">
</head>
0
 

Author Comment

by:VBBRett
ID: 34134139
how do you make it redirect to another page Alfred1?
0
 
LVL 21

Expert Comment

by:Alfred1
ID: 34134160
You need to insert it in your head tag.  In this example it will redirect it in 10 seconds to the default.aspx under test123.com web site.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <META HTTP-EQUIV="refresh" CONTENT="10;URL=http://test123.com/default.aspx; text/html; charset=us-ascii;">
</head>
<body>
.............

Open in new window

0
 
LVL 21

Assisted Solution

by:Alfred1
Alfred1 earned 250 total points
ID: 34134167
Oh by the way, bad example in my previous psot, redirecting it to itself, just assume you are redirecting it to let say order.aspx, so it will be
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default"  %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
    <META HTTP-EQUIV="refresh" CONTENT="10;URL=http://test123.com/order.aspx; text/html; charset=us-ascii;">
</head>
<body>
.............

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Record locking on classic ASP 3 64
Web page design problem 3 41
Validation for a field in asp.net 3 30
Can Selenium do Load Testing? 2 60
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question