Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load


'        Dim loop1, loop2 As Integer
'        Dim arr1(), arr2() As String
'        Dim coll As NameValueCollection
'
'        ' Load ServerVariable collection into NameValueCollection object.
'        coll = Request.ServerVariables
'        ' Get names of all keys into a string array.
'        arr1 = coll.AllKeys
'        For loop1 = 0 To arr1.GetUpperBound(0)
        '            Logger.WebLog("Key: " & arr1(loop1) & "<br>")
'            arr2 = coll.GetValues(loop1) ' Get all values under this key.
'            For loop2 = 0 To arr2.GetUpperBound(0)
        '                Logger.WebLog("Value " & CStr(loop2) & ": " & Server.HtmlEncode(arr2(loop2)) & "<br>")
'            Next loop2
'        Next loop1
'
        '        Logger.WebLog("\Default\Page_Load")

        Dim _hostName As String = Request.Url.Host.ToLower
        Dim _response As String = GetURL(_hostName)
        Redirect301(_response, True)
    End Sub


    Private Function GetURL(ByVal host As String) As String
        Dim blnCBMyAccountUse As String = Application("ENABLE_CHARTER_BUSINESS_MYACCOUNT_SECTION")
        If host.Equals("www.charter.com") OrElse host.Equals("charter.com") Then
            If User.IsInRole("author") Then
                Return "Authors/ContentManager.aspx"
            Else
                Return "http://www.charter.com/Visitors/Home.aspx"
            End If
        Else
            Select Case host

                '-----------------------------------------------------------------------------------------------------
                ' ISSUE #12157  01-28-2011  JLN
                '-----------------------------------------------------------------------------------------------------
                ' Description:  Default redirect for myaccount.charter.com needs to change for Synchronoss Phase 2A.
                '      Change:  Changed the redirect to be database-driven through an Admin.WebConfig table record.
                '               Extended the change for the support.charter.com default redirect, as well.
                '-----------------------------------------------------------------------------------------------------
                Case "www.myaccount.charter.com", "myaccount.charter.com", "www.uat.myaccount.charter.com", "uat.myaccount.charter.com"
                    Return Application(ApplicationKey.SyncProjectURLDefaultMyAccount)

                Case "www.support.charter.com", "support.charter.com", "www.uat.support.charter.com", "uat.support.charter.com"
                    Return Application(ApplicationKey.SyncProjectURLDefaultSupport)

                Case "www.charterlatino.com", "charterlatino.com"
                    Return "http://www.charter.com/Latino/Home.aspx"
                Case "www.update.charter.com", "update.charter.com"
                    Return "https://www.charter.com/order/login.aspx"
                Case "www.chartercom.com", "chartercom.com"
                    Return "http://www.charter.com/Visitors/Home.aspx"
                Case "hawkeyecomputers.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420061"
                    'Case "grantstv.charter.com"
                    '  Return "https://Charter.com/Order/Localize.aspx?AffID=420063"
                Case "gunbergs.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420070"
                Case "worldofcd-rom.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420066"
                Case "merrillhouse.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420064"
                Case "davisoncomputers.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420067"
                Case "searsdealer.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420069"
                Case "selecttechsolutions.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420060"
                Case "ccstech.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420073"
                Case "convergence.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420075"
                Case "qrp.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420076"
                Case "mt.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420077"
                Case "newportwireless.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420074"
                Case "oscars.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420078"
                Case "stereovideo.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420080"
                Case "tvvillage.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420081"
                Case "flanders.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420068"
                Case "excelltec.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420085"
                Case "computersandmore.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420084"
                Case "lebakkens.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420065"
                Case "encore.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420089"
                Case "millars.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420087"
                Case "restainobunbury.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420072"
                Case "nextbuy.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420079"
                Case "bigrapidsfurniture.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420090"
                Case "millbrook.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420086"
                Case "clems.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420092"
                Case "clydes.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420094"
                Case "friendlycomputing.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420053"
                Case "ringcc.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420097"
                Case "computerwarehouse.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420091"
                Case "midstate.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420098"
                Case "computerplusrhi.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420095"
                Case "powercomputingsolutions.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420071"
                Case "whitelake.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420103"
                Case "obc.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420102"
                Case "ue.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420100"
                Case "camicro.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420099"
                Case "becco.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420101"
                Case "dansaudiovideo.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420104"
                Case "sureclick.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420096"
                Case "sunrise-appliance.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420106"
                Case "haarmann.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420005"
                Case "brothersmain.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420015"
                Case "pcsolutions.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420016"
                Case "teamelectronics.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420019"
                Case "victorylane.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420020"
                Case "demo.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=112100"
                Case "moondog.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420028"
                Case "wildwestreno.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420027"
                Case "sunfirewireless.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420029"
                Case "midmichigancomputers.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420031"
                Case "cybertechsystems.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420034"
                Case "vannoords.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420030"
                Case "compucom.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420032"
                Case "thisIsCable.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=120300"
                Case "cam.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420036"
                Case "vandenbergstereo.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420035"
                Case "themacexchange.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420033"
                Case "vonage.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=121800"
                Case "houting.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420039"
                Case "macatawa.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420038"
                Case "scscomputers.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420040"
                Case "csss.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420047"
                Case "computercountry.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420046"
                Case "eaglecomputerservices.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420050"
                Case "bunch.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420049"
                Case "cline.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420051"
                Case "maskertimes.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420044"
                Case "friendlycomputers.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420053"
                Case "silicaappliance.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420048"
                Case "grandcare.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420045"
                Case "raystv.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420037"
                Case "pcoutlet.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420052"
                Case "seckora.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420054"
                Case "gta.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420057"
                Case "virtualpcs.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420056"
                Case "efcom.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420055"
                Case "frs.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420062"
                Case "ctswisconsin.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420059"
                Case "pittco.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420058"
                Case "circuitsplus.charter.com"
                    Return "https://Charter.com/Order/Localize.aspx?AffID=420011"

                    'Case "charterzone.charter.com", "www.charterzone.charter.com"
                    '    Return "http://connect.charter.com/Portal/content/Newsletters/2006/November06/WebLink.aspx?action=Preview&user=Anonymous"
                Case "unsubscribe.charter.com", "www.unsubscribe.charter.com"
                    Return "http://connect.charter.com/portal/settings/privacy.aspx"
                Case "www.chartersafeschools.com", "chartersafeschools.com"
                    Return "http://Charter.com/customers/support.aspx?nonproductitem=303&section=4"
                Case "security.charter.com", "www.security.charter.com"
                    ' issue 16087
                    Return "http://www.charter.com/customers/support.aspx?menuitem=3&tab=tabols"
                    'Return "http://Charter.com/customers/support.aspx?nonproductitem=303"
                Case "jobs.charter.com", "www.jobs.charter.com"
                    Return "http://www.charter.com/Visitors/Careers.aspx?NonProductItem=600"
                Case "www.charterphone.com", "charterphone.com"
                    Return "http://Charter.com/visitors/products.aspx?menuitem=4"
                Case "support2.charter.com", "www.support2.charter.com"
                    Return "http://Charter.com/customers/support.aspx"
                Case "charter-al.com", "www.charter-al.com"
                    Return "http://Charter.com/visitors/products.aspx?menuitem=3"
                    'Case "charterzone.charter.com", "www.charterzone.charter.com"
                    '    Return "http://connect.charter.com/Portal/content/Newsletters/2006/November06/WebLink.aspx?action=Preview&user=Anonymous"

                Case "business.charter.com"
                    '#########################################
                    'sdola 5-20-08
                    'Added for Charter Business
                    '#########################################
                    If Not (blnCBMyAccountUse Is Nothing) Then
                        Select Case blnCBMyAccountUse.Trim().ToUpper()
                            Case "T"
                                Return "https://www.business.charter.com/order/CBLogin.aspx"
                            Case Else
                                Return "https://www.charter.com/order/login.aspx"
                        End Select
                    End If

                Case "business.cc2uatx.chartercom.com"
                    '#########################################
                    'sdola 5-20-08
                    'Added for Charter Business
                    '#########################################
                    If Not (blnCBMyAccountUse Is Nothing) Then
                        Select Case blnCBMyAccountUse.Trim().ToUpper()
                            Case "T"
                                Return "https://business.cc2uatx.chartercom.com/order/CBLogin.aspx"
                            Case Else
                                Return "https://cc2uatx.chartercom.com/order/login.aspx"
                        End Select
                    End If

                Case Else
                    If User.IsInRole("author") Then
                        Return "Authors/ContentManager.aspx"
                    Else
                        Return "/Visitors/Home.aspx"
                    End If
            End Select
        End If
        Return String.Empty
    End Function

    Private Sub Redirect301(ByVal url As String, ByVal endResponse As Boolean)

        Dim context As System.Web.HttpContext = System.Web.HttpContext.Current

        If Not context Is Nothing Then

            If Not url.Equals(String.Empty) Then
                '***************************************************
                ' 6/3/08 - Jonathan Parks
                '***************************************************
                ' added code here to block search bots from crawling
                ' the site if we are not pointing to PROD.WEBSERVER
                '***************************************************
                If ConfigurationManager.AppSettings("ConfigLocation").ToLower <> "prod.webserver" Then
                    context.Response.AddHeader("X-Robots-Tag", "noindex, nofollow")
                End If
                '***************************************************

                context.Response.Status = "301 Moved Permanently"
                context.Response.AddHeader("Location", url)
                context.Response.End()

            End If

        End If

    End Sub
End Class