Solved

Take web site down for maintenance

Posted on 2014-02-19
4
373 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
[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
  • 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

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!

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 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