Solved

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

Posted on 2010-11-14
9
645 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
Independent Software Vendors: 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…

740 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