Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: comparing strings?


Message #1 by "John Hamman {Hamman Interactive}" <johnhamman@C...> on Fri, 19 Apr 2002 17:07:09 -0400
hey all,
does anyone know how to check if for example a string is in another string?
for example if i had the stringA ="/foldera/folderb/page.aspx" and i wanted
to see if stringB="/foldera/" was in string A?  and return true or false.
how would i do this? I know how to do it in asp but not asp.net
john

-----Original Message-----
From: John Hamman {Hamman Interactive} [mailto:johnhamman@C...]
Sent: Friday, April 19, 2002 4:16 PM
To: aspx_beginners
Subject: [aspx_beginners] Global.asax wont process sub from assembly.


Hi all. I have created a redirection script to run in the global.asax file.
The problem is that it doesnt see to work. if i cut the same code and past
it directly into the global.asax file it works great but if i call it
instead from the global.asax file it doesnt work? any ideas whats going on?
John

this works: global.asax.vb
----------------------------------------------------------------------------
-----
Imports System
Imports System.IO
Imports System.Web

Public Class Global
    Inherits System.Web.HttpApplication
 Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        Session.Timeout = 15
        Dim host As String = Request.ServerVariables("SERVER_NAME").ToLower
        Dim ServerDir As String = ""
        Dim PageURL As String
        Select Case host
            Case "cbo.hammaninteractive.com"
                ServerDir = "/c_CBO"
            Case "cboadmin.hammaninteractive.com"
                ServerDir = "/c_CboAdmin"
            Case "www.mwpsupply.com"
                ServerDir = "/c_mwp"
            Case "mwpsupply.com"
                ServerDir = "/c_mwp"
            Case "www.americangolfclassics.com"
                ServerDir = "/c_AmGolf"
            Case "americangolfclassics.com"
                ServerDir = "/c_AmGolf"
            Case "amadmin.americangolfclassics.com"
                ServerDir = "/c_AmGolf/AmAdmin"
            Case "plumbline-ministries.org"
                ServerDir = "/c_PLM"
            Case "www.plumbline-ministries.org"
                ServerDir = "/c_PLM"
            Case "areahomeowner.com"
                ServerDir = "/c_AH"
            Case "www.areahomeowner.com"
                ServerDir = "/c_AH"
            Case "bdg.hammaninteractive.com"
                ServerDir = "/c_BDG"
            Case Else
                ServerDir = "/internet.marketing.solutions"
        End Select

        Response.Redirect(ServerDir)
    End Sub

End Class
--------------------------------------------------------------
This doesnt:
global.asax.vb and redir.vb

'global.asax.vb
'-------------------
Imports System
Imports System.IO
Imports System.Web
Imports hi.redir
Public Class Global
    Inherits System.Web.HttpApplication
 Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        Session.Timeout = 15
        Dim host As String = Request.ServerVariables("SERVER_NAME").ToLower
        Dim obj As redir.Go_to
        Call obj.newhost(host)
  End Sub
End Class






'Redir.vb
'----------------------
Imports System.Web
Imports System.Web.SessionState
Imports System.Web.HttpContext

Namespace redir
    Public Class Go_to
        Public Sub newhost(ByVal host As String)
            Dim ServerDir As String = ""
            Dim PageURL As String
            Select Case host
                Case "cbo.hammaninteractive.com"
                    ServerDir = "/c_CBO"
                Case "cboadmin.hammaninteractive.com"
                    ServerDir = "/c_CboAdmin"
                Case "www.mwpsupply.com"
                    ServerDir = "/c_mwp"
                Case "mwpsupply.com"
                    ServerDir = "/c_mwp"
                Case "www.americangolfclassics.com"
                    ServerDir = "/c_AmGolf"
                Case "americangolfclassics.com"
                    ServerDir = "/c_AmGolf"
                Case "amadmin.americangolfclassics.com"
                    ServerDir = "/c_AmGolf/AmAdmin"
                Case "plumbline-ministries.org"
                    ServerDir = "/c_PLM"
                Case "www.plumbline-ministries.org"
                    ServerDir = "/c_PLM"
                Case "areahomeowner.com"
                    ServerDir = "/c_AH"
                Case "www.areahomeowner.com"
                    ServerDir = "/c_AH"
                Case "bdg.hammaninteractive.com"
                    ServerDir = "/c_BDG"
                Case Else
                    ServerDir = "/internet.marketing.solutions"
            End Select


            Current.Response.Redirect(ServerDir)
        End Sub

    End Class
End Namespace



Message #2 by "Minh T. Nguyen" <nguyentriminh@y...> on Fri, 19 Apr 2002 14:13:15 -0700
John,

if (stringA.IndexOf(stringB) > -1)
	// stringB is in stringA
else
	// it's not

Hope this helps you,
Minh.

-----Original Message-----
From: John Hamman {Hamman Interactive} [mailto:johnhamman@C...] 
Sent: Friday, April 19, 2002 2:07 PM
To: aspx_beginners
Subject: [aspx_beginners] comparing strings?


hey all,
does anyone know how to check if for example a string is in another
string?
for example if i had the stringA ="/foldera/folderb/page.aspx" and i
wanted
to see if stringB="/foldera/" was in string A?  and return true or
false.
how would i do this? I know how to do it in asp but not asp.net
john

Message #3 by "John Hamman {Hamman Interactive}" <johnhamman@C...> on Fri, 19 Apr 2002 17:21:27 -0400
OUTSTANDING! thanks that was exactly what i was looking for. Is there
somewhere that i can find these functions online so i dont have to ask the
list all the time?
John

-----Original Message-----
From: Minh T. Nguyen [mailto:nguyentriminh@y...]
Sent: Friday, April 19, 2002 5:13 PM
To: aspx_beginners
Subject: [aspx_beginners] RE: comparing strings?


John,

if (stringA.IndexOf(stringB) > -1)
	// stringB is in stringA
else
	// it's not

Hope this helps you,
Minh.

-----Original Message-----
From: John Hamman {Hamman Interactive} [mailto:johnhamman@C...]
Sent: Friday, April 19, 2002 2:07 PM
To: aspx_beginners
Subject: [aspx_beginners] comparing strings?


hey all,
does anyone know how to check if for example a string is in another
string?
for example if i had the stringA ="/foldera/folderb/page.aspx" and i
wanted
to see if stringB="/foldera/" was in string A?  and return true or
false.
how would i do this? I know how to do it in asp but not asp.net
john



Message #4 by "Minh T. Nguyen" <nguyentriminh@y...> on Fri, 19 Apr 2002 14:32:14 -0700
John,

	Well, I use VS.NET, so all the documentation comes free of
charge as drop-down list items while editing code (IntelliSense). As for
online documentation, I guess you can go to
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/h
tml/frlrfSystemGlobalizationCompareInfoClassIndexOfTopic.asp, but MSDN
library has such a horrible navigation.

Good luck,
Minh.

-----Original Message-----
From: John Hamman {Hamman Interactive} [mailto:johnhamman@C...] 
Sent: Friday, April 19, 2002 2:21 PM
To: aspx_beginners
Subject: [aspx_beginners] RE: comparing strings?


OUTSTANDING! thanks that was exactly what i was looking for. Is there
somewhere that i can find these functions online so i dont have to ask
the
list all the time?
John

Message #5 by "J House" <jesse@s...> on Sun, 21 Apr 2002 18:19:06
> Is there somewhere that i can find these functions online so i dont have 
to ask the list all the time?

Start > Programs > Microsoft .NET Framework SDK > Documentation

  Return to Index