• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

Take web site down for maintenance

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
Jerry Miller
Asked:
Jerry Miller
  • 2
  • 2
1 Solution
 
skipper68Commented:
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
 
Jerry MillerAuthor Commented:
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
 
Jerry MillerAuthor Commented:
Thanks again for the kick in the brain to get me going!
0
 
skipper68Commented:
You're welcome.  We all need those sometimes.  Glad I could help.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now