Imports Microsoft.VisualBasic

Public Class SubDomainHandler
    Implements IHttpHandler

    Public ReadOnly Property IsReusable() As Boolean Implements System.Web.IHttpHandler.IsReusable
        Get
            Return True
        End Get
    End Property

    Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
        Dim url As String
        Dim host As String = context.Request.Url.Host.ToLower
        url = GetURL(host)
        Redirect(url, True)
    End Sub

    Private Function GetURL(ByVal host As String) As String
        Select Case host
            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"
                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/content/Newsletters/2006/November06/WebLink.aspx?action=Preview&user=Anonymous"
            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 "support.charter.com", "www.support.charter.com"
                Return "http://Charter.com/customers/support.aspx"
                '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 "/gld/Default.aspx"
                Return "/Visitors/lookforservice.aspx"
            Case "/mwd/fortworth/Default.aspx"
                Return "/Visitors/lookforservice.aspx"
            Case "/ned/Default.aspx"
                Return "/Visitors/lookforservice.aspx"
            Case "/wd/Default.aspx"
                Return "/Visitors/lookforservice.aspx"

            Case "/showtimexbox/Default.aspx"
                Return "http://connect.charter.com/landing/showtimexboxintro.aspx"
            Case "/connecttv/Default.aspx"
                Return "http://connect.charter.com/landing/movingconnecttv.aspx"
            Case "/connect2/Default.aspx"
                Return "http://connect.charter.com/landing/movingconnect2.aspx"
            Case "/iwantcable/Default.aspx"
                Return "http://connect.charter.com/landing/movingiwantcable.aspx"
            Case "/getcable/Default.aspx"
                Return "http://connect.charter.com/landing/movinggetcable.aspx"
            Case "/ineedcabl/Default.aspx"
                Return "http://connect.charter.com/landing/movingineedcable.aspx"
            Case "/ineedcable/Default.aspx"
                Return "http://connect.charter.com/landing/movingineedcable.aspx"
            Case "/ondemand/Default.aspx"
                Return "/Visitors/Products.aspx?Productitem=9"
            Case "/ppv/Default.aspx"
                Return "/Visitors/Products.aspx?Productitem=8"
            Case "/telephone/Default.aspx"
                Return "/Visitors/Products.aspx?MenuItem=4"
            Case "/security/Default.aspx"
                Return "/Visitors/Products.aspx?NonProductitem=303"
            Case "/referafriend/Default.aspx"
                Return "/Visitors/general.aspx?ownerid=3"
            Case "/espnsweepstakes/Default.aspx"
                Return "/Visitors/General.aspx?OwnerID=1"
            Case "/guide/Default.aspx"
                Return "/Visitors/general.aspx?ownerid=4"

            Case Else
                ' if not matched with any of above affiliates return charters affiliate
                Return "https://Charter.com/Visitors/Home.aspx"
        End Select
        Return "https://Charter.com/Visitors/Home.aspx"
    End Function

    Private Sub Redirect(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

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

                If endResponse Then
                    context.Response.End()
                End If
            End If

        End If

    End Sub

End Class
