Solved

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

Posted on 2010-11-14
9
640 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
  • 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now