Home All Groups Group Topic Archive Search About

Can't get Global.asax to execute Sub



Author
23 Feb 2005 6:08 PM
tshad
I have an example I copied from "programming asp.net" (o'reilly) and can't
seem to get the Sub (writefile) to execute.  It displays all the
response.write lines that are called directly, but not any of the
response.write lines from inside the sub.

*******************************************
<%@ Application  Language="VB" %>

<script runat="server">

   protected sub Application_Start(ByVal Sender as Object, _
                                   ByVal e as EventArgs)
      WriteFile("Application Starting")
   end sub

   protected sub Application_End(ByVal Sender as Object, _
                                 ByVal e as EventArgs)
      WriteFile("Application Ending")
   end sub

   protected sub Session_Start(ByVal Sender as Object, _
                               ByVal e as EventArgs)
      Response.Write("Session_Start" + "<br/>")
   end sub

   protected sub Session_End(ByVal Sender as Object, _
                             ByVal e as EventArgs)
      Response.Write("Session_End" + "<br/>")
   end sub

   protected sub Application_Disposed(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_Disposed" + "<br/>")
   end sub

   protected sub Application_Error(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      dim strError as string
      strError = Server.GetLastError().ToString()

      Context.ClearError()

      Response.Write("Application_Error" + "<br/>")
      Response.Write("Error Msg: " & strError + "<br/>")
   end sub

   protected sub Application_BeginRequest(ByVal Sender as Object, _
                                          ByVal e as EventArgs)
      Response.Write("Application_BeginRequest" + "<br/>")
   end sub

   protected sub Application_EndRequest(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_EndRequest" + "<br/>")
   end sub

   protected sub Application_AcquireRequestState(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_AcquireRequestState" + "<br/>")
   end sub

   protected sub Application_AuthenticateRequest(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_AuthenticateRequest" + "<br/>")
   end sub

   protected sub Application_AuthorizeRequest(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_AuthorizeRequest" + "<br/>")
   end sub

   protected sub Application_PostRequestHandlerExecute(ByVal Sender as
Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_PostRequestHandlerExecute" + "<br/>")
   end sub

   protected sub Application_PreRequestHandlerExecute(ByVal Sender as
Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_PreRequestHandlerExecute" + "<br/>")
   end sub

   protected sub Application_PreSendRequestContent(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_PreSendRequestContent" + "<br/>")
   end sub

   protected sub Application_PreSendRequestHeaders(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_PreSendRequestHeaders" + "<br/>")
   end sub

   protected sub Application_ReleaseRequestState(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_ReleaseRequestState" + "<br/>")
   end sub

   protected sub Application_ResolveRequestCache(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_ResolveRequestCache" + "<br/>")
   end sub

   protected sub Application_UpdateRequestCache(ByVal Sender as Object, _
                                        ByVal e as EventArgs)
      Response.Write("Application_UpdateRequestCache" + "<br/>")
   end sub

   sub WriteFile(strText as string)
  response.write("inside WriteFile <br>")
   end sub

</script>
******************************************************************

Do I need to do something else to make this work?

It is a straight global.asax file in the root folder that is executing
correctly on my aspx page (except for the sub).  At the moment I am passing
a string, but since I couldn't get it to work I just put a response.write
line in the sub.

Thanks,

Tom

Author
23 Feb 2005 6:45 PM
Bob Barrows [MVP]
tshad wrote:
> I have an example I copied from "programming asp.net" (o'reilly) and

There was no way for you to know it, but this is a classic asp newsgroup.
While you may be lucky enough to find a dotnet-savvy person here who can
answer your question, you can eliminate the luck factor by posting your
question to a group where those dotnet-savvy people hang out. I suggest
microsoft.public.dotnet.framework.aspnet.

> can't seem to get the Sub (writefile) to execute.  It displays all the
> response.write lines that are called directly, but not any of the
> response.write lines from inside the sub.

The Response object is usually not available in any of these event
procedures, at least in classic asp, and I assume it's the same in dotnet.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Author
23 Feb 2005 8:12 PM
tshad
"Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message
news:OCjsffdGFHA.400@TK2MSFTNGP14.phx.gbl...
> tshad wrote:
>> I have an example I copied from "programming asp.net" (o'reilly) and
>
> There was no way for you to know it, but this is a classic asp newsgroup.
> While you may be lucky enough to find a dotnet-savvy person here who can
> answer your question, you can eliminate the luck factor by posting your
> question to a group where those dotnet-savvy people hang out. I suggest
> microsoft.public.dotnet.framework.aspnet.

Actually, I do use the .net group, but I accidently posted it here.  Sorry.

Tom
Show quote
>
>> can't seem to get the Sub (writefile) to execute.  It displays all the
>> response.write lines that are called directly, but not any of the
>> response.write lines from inside the sub.
>
> The Response object is usually not available in any of these event
> procedures, at least in classic asp, and I assume it's the same in dotnet.
>
> Bob Barrows
> --
> Microsoft MVP - ASP/ASP.NET
> Please reply to the newsgroup. This email account is my spam trap so I
> don't check it very often. If you must reply off-line, then remove the
> "NO SPAM"
>

AddThis Social Bookmark Button