title: Getting Around HttpContext.Current issue
body: <p>Yes there are a lot of posts about this issue and I have tried the suggestions in many of them and none of them have worked.  Please do not tell me that this has been asked already.</p>
  
  <p>I have been asked to update an internal website that interacts with a database.  It was originally created in VS 2003, which we do not have access to anymore so it necessitated an upgrade of the project to VS 2012.  I have one last problem to fix.  The original designer of the site used the following block of code to set the environment so that the correct database could be connected to:</p>
  
  <pre><code>Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
      ' Fires when the application is started
      Select Case LCase(HttpContext.Current.Request.ServerVariables("SERVER_NAME"))
          Case "localhost", "development_domain"
              DB_Environment = "DEVELOPMENT"
  
          Case "staging_ip", "staging_domain"
              DB_Environment = "STAGING"
  
          Case "external_prod_domain", "external_prod_ip", "internal_prod_domain"
              DB_Environment = "PRODUCTION"
      End Select
  End Sub
  </code></pre>
  
  <p>The various environments are in the process of being upgraded to IIS 7.5.  This means that this site now blows up in the dev environment because HttpContext.Current is no longer supported in IIS 7 and later.  </p>
  
  <p>Many of the suggested fixes talk about moving the functionality to Application_BeginRequest method.  I'm not really interested in having this fired off every time a request is made as it is unnecessary, and also it seems to cause issues with the application.  </p>
  
  <p>Part of my problems is I cannot try some of the suggestions as they are coded in C# (with which I am very familiar) and the application is coded in VB (with which I am not so familiar).</p>
  
  <p>Can anyone point me in the right direction as to how I can retrieve the domain to hold in the DB_Environment variable without using the HttpContext.Current method?</p>