Solved

Take web site down for maintenance

Posted on 2014-02-19
4
367 Views
Last Modified: 2014-02-19
I have a requirement in a web application that I am developing in VB.Net to have the ability to take the site offline for maintenance. I have that part down by storing a Boolean value in a table and checking it on the page load of the pages that should be offline. This works fine as it only allows people in the proper roles to access the necessary pages.

However, I need to warn the users that the site is going down in specified amount of time regardless of what page they are on and then have it be unavailable. Can someone direct me on the best way to give the logged in users a pop-up message or other visual notification that they need to save their work because the site is going down?
0
Comment
Question by:Jerry Miller
  • 2
  • 2
4 Comments
 
LVL 9

Accepted Solution

by:
skipper68 earned 500 total points
ID: 39870434
I can see 2 ways:  using a session variable or checking the current date\time and displaying a message accordingly

1. A good article that looks like they are doing the same thing: http://stackoverflow.com/questions/7743762/welcome-message-to-display-on-every-page-using-session

2. On the default page (or every page), you could check to see if the current date is before the maintenance date.  If it is, show a banner at the top in RED BOLD letters notifying that the site will be down for maintenance on xx/xx/xxxx.

Some Pseudo-Code

Dim CurrentDate as Date = Now()
Dim MaintenanceStartDate as Date = 03/01/2014

If CurrentDate <=MaintenanceStartDate
     Response.write "<b><u>Reminder, This site will be down on " & MaintenanceStartDate & " for site maintenance.</u></b>"

End If
0
 
LVL 18

Author Comment

by:Jerry Miller
ID: 39870852
Thanks for the help, I had a huge mental block and couldn't come up with any ideas. I took your second idea and ran with it a bit. Here is what I did:

1)  I put a label on the master page and pulled the datetime / status from the database. This is to display a message to the user what time the system would be unavailable.

Dim implementTime As Date?
        Dim maintenance As Boolean
        Dim projectDBO As New ProjectDataBO
        Dim dataset2 As SqlDataReader = projectDBO.getIsMaintenanceMode()
        Dim message As String = "The system is going down for maintenance at "
        Dim message2 As String = ". Please save your work and log out"
        If dataset2.HasRows Then
            While dataset2.Read()
                If Not dataset2("implementTime") Is DBNull.Value Then
                    implementTime = dataset2("implementTime")
                    maintenance = dataset2("IsMaintenanceMode")
                End If

            End While
        End If
        If maintenance = True Then
            Me.lblMessage.Font.Bold = True
            Me.lblMessage.BackColor = Drawing.Color.Red
            Me.lblMessage.Text = message & implementTime.ToString
        End If

2)  I updated my previous IsMaintenanceMode code on my configurations page to pull in the date as well. This returns true when the date has passed and the flag is true in the database. I added a date field in my database to determine what time to set the system in maintenance mode.

Public Shared ReadOnly Property isMaintenanceMode() As Boolean
            Get
                Dim maintenance As Boolean
                Dim implementTime As Date?
                Dim projectDBO As New ProjectDataBO
                Dim dataset As SqlDataReader = projectDBO.getIsMaintenanceMode()
                If dataset.HasRows Then
                    While dataset.Read()
                        maintenance = dataset("IsMaintenanceMode")
                        If Not dataset("implementTime") Is DBNull.Value Then
                            implementTime = dataset("implementTime")
                        End If

                    End While
                End If
                If implementTime > Now() OrElse implementTime Is Nothing Then
                    Return False
                Else
                    Return maintenance
                End If

            End Get
        End Property

3) Then on each page that needs to be inactive, I add this code. I was already doing this step, so it doesn't require changes across the pages that I have completed. MAINTENANCE_PAGE is a constant that maps to the true URL.

If Configurations.isMaintenanceMode Then
            HttpContext.Current.Response.Redirect(MAINTENANCE_PAGE, False)
End If

A lot of this is because the supervisor that will perform certain functions needs to ensure that the data isn't being updated while they are working. Plus it gives anyone that is working a few minutes before the system is locked. They get the red warning label across the top of the page and after the time has elapsed, the system locks them out.
0
 
LVL 18

Author Closing Comment

by:Jerry Miller
ID: 39870857
Thanks again for the kick in the brain to get me going!
0
 
LVL 9

Expert Comment

by:skipper68
ID: 39870886
You're welcome.  We all need those sometimes.  Glad I could help.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
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…
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

746 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

9 Experts available now in Live!

Get 1:1 Help Now