473,396 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Can't get Global.asax to execute Sub

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_PostRequestHandlerExec ute" + "<br/>")
end sub

protected sub Application_PreRequestHandlerExecute(ByVal Sender as
Object, _
ByVal e as EventArgs)
Response.Write("Application_PreRequestHandlerExecu te" + "<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

Nov 19 '05 #1
9 2356
TShad:
You can't Response.Write within Application_Start...this happens outside the
page handling (more or less). It might be helpful if you explained why you
aren't doing this in Page_Load which is where this sorta stuff belongs....

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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_PostRequestHandlerExec ute" + "<br/>")
end sub

protected sub Application_PreRequestHandlerExecute(ByVal Sender as
Object, _
ByVal e as EventArgs)
Response.Write("Application_PreRequestHandlerExecu te" + "<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

Nov 19 '05 #2
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ed**************@TK2MSFTNGP12.phx.gbl...
TShad:
You can't Response.Write within Application_Start...this happens outside
the
page handling (more or less). It might be helpful if you explained why
you
aren't doing this in Page_Load which is where this sorta stuff belongs....
I am just trying to play with the Global.asax to understand how to set it up
and make some global routines. This was taken from O'Reillys book, but I
took out the write to a text file as that didn't seem to work (I assume as
it was originally writing to the C root.

I was just trying to get the sub to do something. But you explained why it
didn't work where it was. When I call it from the other events, it worked
fine.

Thanks,

Tom
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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_PostRequestHandlerExec ute" + "<br/>")
end sub

protected sub Application_PreRequestHandlerExecute(ByVal Sender as
Object, _
ByVal e as EventArgs)
Response.Write("Application_PreRequestHandlerExecu te" + "<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


Nov 19 '05 #3
Global routines should probably be placed inside their own utility class,
such as:

public sealed class Utility{
private void Utility(){}

public static void WriteLine(string value){
HttpContext.Current.Response.Write(value);
}
...
}
which can then be called via:

Utility.WriteLine("yyy");
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uv**************@TK2MSFTNGP14.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ed**************@TK2MSFTNGP12.phx.gbl...
TShad:
You can't Response.Write within Application_Start...this happens outside
the
page handling (more or less). It might be helpful if you explained why
you
aren't doing this in Page_Load which is where this sorta stuff
belongs....
I am just trying to play with the Global.asax to understand how to set it up and make some global routines. This was taken from O'Reillys book, but I
took out the write to a text file as that didn't seem to work (I assume as
it was originally writing to the C root.

I was just trying to get the sub to do something. But you explained why it didn't work where it was. When I call it from the other events, it worked
fine.

Thanks,

Tom

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
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_PostRequestHandlerExec ute" + "<br/>")
end sub

protected sub Application_PreRequestHandlerExecute(ByVal Sender as
Object, _
ByVal e as EventArgs)
Response.Write("Application_PreRequestHandlerExecu te" + "<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



Nov 19 '05 #4
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OL**************@TK2MSFTNGP09.phx.gbl...
Global routines should probably be placed inside their own utility class,
such as:
I agree.

I just haven't gotten around to building a Class for this yet. I wanted to
use Global.asax so as not to have to define a class and set up a code-behind
page for it. Not sure how to deal with that yet.

Thanks,

Tom
public sealed class Utility{
private void Utility(){}

public static void WriteLine(string value){
HttpContext.Current.Response.Write(value);
}
...
}
which can then be called via:

Utility.WriteLine("yyy");
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uv**************@TK2MSFTNGP14.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ed**************@TK2MSFTNGP12.phx.gbl...
> TShad:
> You can't Response.Write within Application_Start...this happens
> outside
> the
> page handling (more or less). It might be helpful if you explained why
> you
> aren't doing this in Page_Load which is where this sorta stuff belongs....

I am just trying to play with the Global.asax to understand how to set it

up
and make some global routines. This was taken from O'Reillys book, but I
took out the write to a text file as that didn't seem to work (I assume
as
it was originally writing to the C root.

I was just trying to get the sub to do something. But you explained why

it
didn't work where it was. When I call it from the other events, it
worked
fine.

Thanks,

Tom
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:%2******************@TK2MSFTNGP09.phx.gbl...
>> 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_PostRequestHandlerExec ute" +
>> "<br/>")
>> end sub
>>
>> protected sub Application_PreRequestHandlerExecute(ByVal Sender as
>> Object, _
>> ByVal e as EventArgs)
>> Response.Write("Application_PreRequestHandlerExecu te" + "<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
>>
>>
>>
>
>



Nov 19 '05 #5
> I just haven't gotten around to building a Class for this yet. I wanted
to use Global.asax so as not to have to define a class and set up a
code-behind page for it. Not sure how to deal with that yet.
That's like saying that your building a house, and you put the toilet in the
garage so that you wouldn't have to add an extra room. Instead, think of the
needs of the house.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eY**************@TK2MSFTNGP15.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OL**************@TK2MSFTNGP09.phx.gbl...
Global routines should probably be placed inside their own utility class,
such as:


I agree.

I just haven't gotten around to building a Class for this yet. I wanted
to use Global.asax so as not to have to define a class and set up a
code-behind page for it. Not sure how to deal with that yet.

Thanks,

Tom

public sealed class Utility{
private void Utility(){}

public static void WriteLine(string value){
HttpContext.Current.Response.Write(value);
}
...
}
which can then be called via:

Utility.WriteLine("yyy");
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uv**************@TK2MSFTNGP14.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ed**************@TK2MSFTNGP12.phx.gbl...
> TShad:
> You can't Response.Write within Application_Start...this happens
> outside
> the
> page handling (more or less). It might be helpful if you explained
> why
> you
> aren't doing this in Page_Load which is where this sorta stuff

belongs....

I am just trying to play with the Global.asax to understand how to set
it

up
and make some global routines. This was taken from O'Reillys book, but
I
took out the write to a text file as that didn't seem to work (I assume
as
it was originally writing to the C root.

I was just trying to get the sub to do something. But you explained why

it
didn't work where it was. When I call it from the other events, it
worked
fine.

Thanks,

Tom
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:%2******************@TK2MSFTNGP09.phx.gbl...
>> 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_PostRequestHandlerExec ute" +
>> "<br/>")
>> end sub
>>
>> protected sub Application_PreRequestHandlerExecute(ByVal Sender as
>> Object, _
>> ByVal e as EventArgs)
>> Response.Write("Application_PreRequestHandlerExecu te" +
>> "<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
>>
>>
>>
>
>



Nov 19 '05 #6
On 23 Feb 2005, "tshad" <ts**********@ftsolutions.com> postulated in
news:eY**************@TK2MSFTNGP15.phx.gbl:
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:OL**************@TK2MSFTNGP09.phx.gbl...
Global routines should probably be placed inside their own utility class, such as:
I agree.

I just haven't gotten around to building a Class for this yet. I

wanted to use Global.asax so as not to have to define a class and set up a code-behind page for it. Not sure how to deal with that yet.

Thanks,

Tom

public sealed class Utility{
private void Utility(){}

public static void WriteLine(string value){
HttpContext.Current.Response.Write(value);
}
...
}
which can then be called via:

Utility.WriteLine("yyy");
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uv**************@TK2MSFTNGP14.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:ed**************@TK2MSFTNGP12.phx.gbl...
> TShad:
> You can't Response.Write within Application_Start...this happens > outside
> the
> page handling (more or less). It might be helpful if you explained why > you
> aren't doing this in Page_Load which is where this sorta stuff

belongs....

I am just trying to play with the Global.asax to understand how to set it
up
and make some global routines. This was taken from O'Reillys
book, but I took out the write to a text file as that didn't seem to work (I assume as
it was originally writing to the C root.

I was just trying to get the sub to do something. But you explained why it
didn't work where it was. When I call it from the other events,
it worked
fine.

Thanks,

Tom
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:%2******************@TK2MSFTNGP09.phx.gbl...
>> 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_PostRequestHandlerExec ute" +
>> "<br/>")
>> end sub
>>
>> protected sub Application_PreRequestHandlerExecute(ByVal Sender as >> Object, _
>> ByVal e as EventArgs)
>> Response.Write("Application_PreRequestHandlerExecu te" + "<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
>>
>>
>>
>
>




Tom,

Are you still fighting this battle?

With a static class like the one Karl describes, there is no "code-
behind" per se...the Util.cs file is the ONLY file. In other words,
there's no ASPX file associated with a static class like this.

-- ipgrunt
Nov 19 '05 #7
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I just haven't gotten around to building a Class for this yet. I wanted
to use Global.asax so as not to have to define a class and set up a
code-behind page for it. Not sure how to deal with that yet.
That's like saying that your building a house, and you put the toilet in
the garage so that you wouldn't have to add an extra room. Instead, think
of the needs of the house.


Actually, I am looking at the needs of the house, just not all at once.

I want to understand what is best to put in the Global.asax and what is best
in a class. So I am trying to get the Global to work first and understand
that and then build a class (actually I am building a database class now)
and play with both.

Thanks,

Tom
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eY**************@TK2MSFTNGP15.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OL**************@TK2MSFTNGP09.phx.gbl...
Global routines should probably be placed inside their own utility
class,
such as:


I agree.

I just haven't gotten around to building a Class for this yet. I wanted
to use Global.asax so as not to have to define a class and set up a
code-behind page for it. Not sure how to deal with that yet.

Thanks,

Tom

public sealed class Utility{
private void Utility(){}

public static void WriteLine(string value){
HttpContext.Current.Response.Write(value);
}
...
}
which can then be called via:

Utility.WriteLine("yyy");
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uv**************@TK2MSFTNGP14.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ed**************@TK2MSFTNGP12.phx.gbl...
> TShad:
> You can't Response.Write within Application_Start...this happens
> outside
> the
> page handling (more or less). It might be helpful if you explained
> why
> you
> aren't doing this in Page_Load which is where this sorta stuff
belongs....

I am just trying to play with the Global.asax to understand how to set
it
up
and make some global routines. This was taken from O'Reillys book, but
I
took out the write to a text file as that didn't seem to work (I assume
as
it was originally writing to the C root.

I was just trying to get the sub to do something. But you explained
why
it
didn't work where it was. When I call it from the other events, it
worked
fine.

Thanks,

Tom
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "tshad" <ts**********@ftsolutions.com> wrote in message
> news:%2******************@TK2MSFTNGP09.phx.gbl...
>> 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_PostRequestHandlerExec ute" +
>> "<br/>")
>> end sub
>>
>> protected sub Application_PreRequestHandlerExecute(ByVal Sender
>> as
>> Object, _
>> ByVal e as EventArgs)
>> Response.Write("Application_PreRequestHandlerExecu te" +
>> "<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
>>
>>
>>
>
>



Nov 19 '05 #8
> Tom,

Are you still fighting this battle?

With a static class like the one Karl describes, there is no "code-
behind" per se...the Util.cs file is the ONLY file. In other words,
there's no ASPX file associated with a static class like this.

Yup.

I am trying to understand both (code-behind and classes by themselves).

I just got VS trial version and am building a myUtils.vb file that has a
database class in it. I also have a Global.asax (not compiled yet) to
understand shared functions. I wasn't sure how to set it up in VS so I
decided to go this way first. Since I assume that Global.asax and
Global.asax.vb is essentially the same, except that in Global.asax.vb I
don't need the script tags.

In my other post, I have the function being called (which is farther that I
got before) but I am getting an error.

I decided to start with the database class as I have about 50 pages built
(no code-behind yet) but lots of database calls and I would like to simplify
these.

I have to start somewhere.

Tom
Nov 19 '05 #9
> I want to understand what is best to put in the Global.asax and what is
best in a class. So I am trying to get the Global to work first and
understand that and then
The Global.asax file IS a class. It is a collection of Application-level
event handlers. It is specific to the application.

If you think of classes the way you think of files and folders in your file
system, that may help. Just as folders and sub-folders in your computer make
finding a specific file easier, so classes should be organized in such a way
that you can easily identify the class that handles a given realm of
functionality. A class is a group of related data and process. So, if the
Global class is a collection of Application-level event handlers, that is
what it should be. A Page class is a collection of related UI data and
process that relates to an individual page Request and Response.

If you look at the CLR, you can see excellent examples of class
organization. The Math class, for example, is not much more than a bunch of
static Math functions. The File class has all the functionality needed to
work with Files. So, it wouldn't make sense to look in the Math class for a
function to open a file than it would to put your toilet in the garage.

I hope that clears things up a bit.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:Ou**************@tk2msftngp13.phx.gbl... "Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I just haven't gotten around to building a Class for this yet. I wanted
to use Global.asax so as not to have to define a class and set up a
code-behind page for it. Not sure how to deal with that yet.


That's like saying that your building a house, and you put the toilet in
the garage so that you wouldn't have to add an extra room. Instead, think
of the needs of the house.


Actually, I am looking at the needs of the house, just not all at once.

I want to understand what is best to put in the Global.asax and what is
best in a class. So I am trying to get the Global to work first and
understand that and then build a class (actually I am building a database
class now) and play with both.

Thanks,

Tom

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:eY**************@TK2MSFTNGP15.phx.gbl...
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OL**************@TK2MSFTNGP09.phx.gbl...
Global routines should probably be placed inside their own utility
class,
such as:

I agree.

I just haven't gotten around to building a Class for this yet. I wanted
to use Global.asax so as not to have to define a class and set up a
code-behind page for it. Not sure how to deal with that yet.

Thanks,

Tom

public sealed class Utility{
private void Utility(){}

public static void WriteLine(string value){
HttpContext.Current.Response.Write(value);
}
...
}
which can then be called via:

Utility.WriteLine("yyy");
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"tshad" <ts**********@ftsolutions.com> wrote in message
news:uv**************@TK2MSFTNGP14.phx.gbl...
> "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
> net>
> wrote in message news:ed**************@TK2MSFTNGP12.phx.gbl...
> > TShad:
> > You can't Response.Write within Application_Start...this happens
> > outside
> > the
> > page handling (more or less). It might be helpful if you explained
> > why
> > you
> > aren't doing this in Page_Load which is where this sorta stuff
belongs....
>
> I am just trying to play with the Global.asax to understand how to set
> it
up
> and make some global routines. This was taken from O'Reillys book,
> but I
> took out the write to a text file as that didn't seem to work (I
> assume as
> it was originally writing to the C root.
>
> I was just trying to get the sub to do something. But you explained
> why
it
> didn't work where it was. When I call it from the other events, it
> worked
> fine.
>
> Thanks,
>
> Tom
> >
> > Karl
> >
> > --
> > MY ASP.Net tutorials
> > http://www.openmymind.net/
> >
> >
> > "tshad" <ts**********@ftsolutions.com> wrote in message
> > news:%2******************@TK2MSFTNGP09.phx.gbl...
> >> 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_PostRequestHandlerExec ute" +
> >> "<br/>")
> >> end sub
> >>
> >> protected sub Application_PreRequestHandlerExecute(ByVal Sender
> >> as
> >> Object, _
> >> ByVal e as EventArgs)
> >> Response.Write("Application_PreRequestHandlerExecu te" +
> >> "<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
> >>
> >>
> >>
> >
> >
>
>



Nov 19 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: tshad | last post by:
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...
2
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
5
by: ad | last post by:
The Global.asax is code-inside with default. How to change Global.asax to code-behind?
2
by: Steve | last post by:
I am new to this newsgroup & to .NET in general. I have been playing around with Visual Studio .NET, building and rendering web pages using VB "code behind" files. My problem / question is; How...
6
by: Mark Rae | last post by:
Hi, When you create a new web site in VS.NET 2005, it doesn't contain a Global.asax file by default and, when you add one manually, it creates a Global.asax file with in-line code e.g. <%@...
0
by: hynek.cihlar | last post by:
A strange behaviour thatI found in ASP.NET 2.0. I am trying to issue a callback request (handled by ICallbackEventHandler and RaiseCallbackEvent) and a regular GET request in the client browser...
4
by: Larry Epn | last post by:
Simple question: I have a c# asp.net project that was given to me. It has the c# code within the <scriptsection of the global.asax file. I would rather have it in separate files; e.g.,...
4
by: Hardy Wang | last post by:
Hi all, In order to solve code-behind of global.asax problem, I removed the code from global.asax, and just leave one line "<%@ Application Language="C#" Inherits="Global"%>" in this file. Then I...
3
by: teo | last post by:
I have two .aspx pages they use two different Global.asax files when I "Publish" the first .aspx page, its Global.asax is transformed in App_global.asax.compiled App_global.asax.dll to put...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.