By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,625 Members | 1,274 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,625 IT Pros & Developers. It's quick & easy.

Can't get Global.asax to execute Sub

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
"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

P: n/a
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

P: n/a
"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

P: n/a
> 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

P: n/a
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

P: n/a
"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

P: n/a
> 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

P: n/a
> 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 discussion thread is closed

Replies have been disabled for this discussion.