|
 |
aspx_beginners thread: Global.asax wont process sub from assembly.
Message #1 by "John Hamman {Hamman Interactive}" <johnhamman@C...> on Fri, 19 Apr 2002 16:16:23 -0400
|
|
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 "Peter Lawrence" <peter.lawrence@p...> on Fri, 19 Apr 2002 23:01:02 +0100
|
|
Well my guess (and I'm learning here too) is that global.asax won't have
anything to do with Request and Response objects. They apply to the HTTP
requests and responses to and from the browser, and when global.asax wants
to run, there isn't a browser "attached". You could test this out by
hardcoding those lines.
BTW: The other problem I have found with global.asax is that it's current
directory changes - worth bearing in mind depending on how you end up
getting your host name. It appears that ASP.NET re-starts periodically which
re-runs global.asax Application_OnStart, and depending on which directory
the next page comes from below the application root, that's the current
directory for global.asax. (I wanted to read a UDL file from the application
root, but Server.MapPath() looks for the file in different directories and
doesn't always work).
Peter Lawrence
----- Original Message -----
From: "John Hamman {Hamman Interactive}" <johnhamman@C...>
To: "aspx_beginners" <aspx_beginners@p...>
Sent: Friday, April 19, 2002 9:16 PM
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
>
>
>
|
|
 |