Solved

Take web site down for maintenance

Posted on 2014-02-19
4
370 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Gridview selected row 9 47
in Dot net,lastest version of MVC 3 24
cannot connect to sqlserver 8 29
ASP.NET MVC identity 6 27
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 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