L
Leon
Please help, what I'm I doing wrong?????
--> This following code will not run correctly, no syntax errors, but..
--> execution error = The subdomain does not exist in database.... "but it
does in the database"
--> I think this is the problem in the code but don't know how to fix =
Me.CommandCheckSDM.Parameters(1).Value = (sdm.Replace(sdmurl, "$1"))
--> Heres the actual live code...
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
'Comments: Fires at the beginning of each request
'Comments: Get database connection from config file
Dim myConnectionString As String
myConnectionString =
ConfigurationSettings.AppSettings("myConnectionString")
Me.Connection.ConnectionString = myConnectionString
'Comments: Retrieving subdomain ('sdm') name from url
Dim sdmurl As String = Request.Url.ToString
Dim sdm As Regex
sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
'Comments: Checking Subdomain name and retrieving account id
Me.CommandCheckSDM.Parameters(1).Value = (sdm.Replace(sdmurl, "$1"))
Me.Connection.Open()
Me.CommandCheckSDM.ExecuteNonQuery()
Me.Connection.Close()
If Me.CommandCheckSDM.Parameters(0).Value < 0 Then
If Me.CommandCheckSDM.Parameters(0).Value = -1 Then
Throw New Exception("The subdomain does not exist in database.")
ElseIf Me.CommandCheckSDM.Parameters(0).Value = -2 Then
Throw New Exception("The subdomain is not active.")
End If
Else
'Comments: Tranfer user to index website
Context.Items("AccountID") =
Me.CommandCheckSDM.Parameters(0).Value()
Server.Transfer("index/MyPage.aspx")
End If
End Sub
--> This following code will not run correctly, no syntax errors, but..
--> execution error = The subdomain does not exist in database.... "but it
does in the database"
--> I think this is the problem in the code but don't know how to fix =
Me.CommandCheckSDM.Parameters(1).Value = (sdm.Replace(sdmurl, "$1"))
--> Heres the actual live code...
Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
'Comments: Fires at the beginning of each request
'Comments: Get database connection from config file
Dim myConnectionString As String
myConnectionString =
ConfigurationSettings.AppSettings("myConnectionString")
Me.Connection.ConnectionString = myConnectionString
'Comments: Retrieving subdomain ('sdm') name from url
Dim sdmurl As String = Request.Url.ToString
Dim sdm As Regex
sdm = New Regex("http://(?!www\.)(.*)(\.domain\.com.*)")
'Comments: Checking Subdomain name and retrieving account id
Me.CommandCheckSDM.Parameters(1).Value = (sdm.Replace(sdmurl, "$1"))
Me.Connection.Open()
Me.CommandCheckSDM.ExecuteNonQuery()
Me.Connection.Close()
If Me.CommandCheckSDM.Parameters(0).Value < 0 Then
If Me.CommandCheckSDM.Parameters(0).Value = -1 Then
Throw New Exception("The subdomain does not exist in database.")
ElseIf Me.CommandCheckSDM.Parameters(0).Value = -2 Then
Throw New Exception("The subdomain is not active.")
End If
Else
'Comments: Tranfer user to index website
Context.Items("AccountID") =
Me.CommandCheckSDM.Parameters(0).Value()
Server.Transfer("index/MyPage.aspx")
End If
End Sub