Solved

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

Posted on 2010-11-14
9
643 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

840 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