Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Application_BeginRequest With RegEX Question?

Reply
Thread Tools

Application_BeginRequest With RegEX Question?

 
 
Leon
Guest
Posts: n/a
 
      06-16-2005
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("myConnectionStr ing")
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


 
Reply With Quote
 
 
 
 
tom.pesterDeLeTeTHISSS@pandora.be
Guest
Posts: n/a
 
      06-16-2005
Try to norrow down the problem by feeding the regex possible inputs.

If the subdomain exist in your database than the regex doesnt give back the
correct result.

Which strings are presented to the regex that fail but should be recognized?

Let me know if you have any more questions..

Cheers,
Tom Pester

> 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("myConnectionStr ing")
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How make regex that means "contains regex#1 but NOT regex#2" ?? seberino@spawar.navy.mil Python 3 07-01-2008 03:06 PM
Application_BeginRequest questions JezB ASP .Net 3 07-06-2004 04:27 PM
Session Start / Application_BeginRequest Issues =?Utf-8?B?UGF1bCBEYWx5IChNQ1Ap?= ASP .Net 3 07-04-2004 06:22 PM
Using CommandArgument in Application_BeginRequest Amil ASP .Net 1 02-19-2004 11:27 PM
Application_BeginRequest is fired 2 times each time I do an action on the browser... Cynic07 ASP .Net 1 07-31-2003 12:28 PM



Advertisments