Solved

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

Posted on 2010-11-14
9
636 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
 
LVL 21

Expert Comment

by:Alfred1
ID: 34134075
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

758 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

22 Experts available now in Live!

Get 1:1 Help Now