I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _
ByVal e as EventArgs)
WriteFile("Appl ication Starting")
end sub
protected sub Application_End (ByVal Sender as Object, _
ByVal e as EventArgs)
WriteFile("Appl ication Ending")
end sub
protected sub Session_Start(B yVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Session_St art" + "<br/>")
end sub
protected sub Session_End(ByV al Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Session_En d" + "<br/>")
end sub
protected sub Application_Dis posed(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Di sposed" + "<br/>")
end sub
protected sub Application_Err or(ByVal Sender as Object, _
ByVal e as EventArgs)
dim strError as string
strError = Server.GetLastE rror().ToString ()
Context.ClearEr ror()
Response.Write( "Application_Er ror" + "<br/>")
Response.Write( "Error Msg: " & strError + "<br/>")
end sub
protected sub Application_Beg inRequest(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Be ginRequest" + "<br/>")
end sub
protected sub Application_End Request(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_En dRequest" + "<br/>")
end sub
protected sub Application_Acq uireRequestStat e(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Ac quireRequestSta te" + "<br/>")
end sub
protected sub Application_Aut henticateReques t(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Au thenticateReque st" + "<br/>")
end sub
protected sub Application_Aut horizeRequest(B yVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Au thorizeRequest" + "<br/>")
end sub
protected sub Application_Pos tRequestHandler Execute(ByVal Sender as
Object, _
ByVal e as EventArgs)
Response.Write( "Application_Po stRequestHandle rExecute" + "<br/>")
end sub
protected sub Application_Pre RequestHandlerE xecute(ByVal Sender as
Object, _
ByVal e as EventArgs)
Response.Write( "Application_Pr eRequestHandler Execute" + "<br/>")
end sub
protected sub Application_Pre SendRequestCont ent(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>")
end sub
protected sub Application_Pre SendRequestHead ers(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>")
end sub
protected sub Application_Rel easeRequestStat e(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Re leaseRequestSta te" + "<br/>")
end sub
protected sub Application_Res olveRequestCach e(ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Re solveRequestCac he" + "<br/>")
end sub
protected sub Application_Upd ateRequestCache (ByVal Sender as Object, _
ByVal e as EventArgs)
Response.Write( "Application_Up dateRequestCach e" + "<br/>")
end sub
sub WriteFile(strTe xt 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 9 2389
TShad:
You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l... I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ ByVal e as EventArgs) WriteFile("Appl ication Starting") end sub
protected sub Application_End (ByVal Sender as Object, _ ByVal e as EventArgs) WriteFile("Appl ication Ending") end sub
protected sub Session_Start(B yVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Session_St art" + "<br/>") end sub
protected sub Session_End(ByV al Sender as Object, _ ByVal e as EventArgs) Response.Write( "Session_En d" + "<br/>") end sub
protected sub Application_Dis posed(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Di sposed" + "<br/>") end sub
protected sub Application_Err or(ByVal Sender as Object, _ ByVal e as EventArgs) dim strError as string strError = Server.GetLastE rror().ToString ()
Context.ClearEr ror()
Response.Write( "Application_Er ror" + "<br/>") Response.Write( "Error Msg: " & strError + "<br/>") end sub
protected sub Application_Beg inRequest(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Be ginRequest" + "<br/>") end sub
protected sub Application_End Request(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_En dRequest" + "<br/>") end sub
protected sub Application_Acq uireRequestStat e(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Ac quireRequestSta te" + "<br/>") end sub
protected sub Application_Aut henticateReques t(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Au thenticateReque st" + "<br/>") end sub
protected sub Application_Aut horizeRequest(B yVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Au thorizeRequest" + "<br/>") end sub
protected sub Application_Pos tRequestHandler Execute(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Po stRequestHandle rExecute" + "<br/>") end sub
protected sub Application_Pre RequestHandlerE xecute(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Pr eRequestHandler Execute" + "<br/>") end sub
protected sub Application_Pre SendRequestCont ent(ByVal Sender as Object,
_ ByVal e as EventArgs) Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>") end sub
protected sub Application_Pre SendRequestHead ers(ByVal Sender as Object,
_ ByVal e as EventArgs) Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>") end sub
protected sub Application_Rel easeRequestStat e(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Re leaseRequestSta te" + "<br/>") end sub
protected sub Application_Res olveRequestCach e(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Re solveRequestCac he" + "<br/>") end sub
protected sub Application_Upd ateRequestCache (ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Up dateRequestCach e" + "<br/>") end sub
sub WriteFile(strTe xt 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
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:ed******** ******@TK2MSFTN GP12.phx.gbl... TShad: You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message news:%2******** **********@TK2M SFTNGP09.phx.gb l... I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ ByVal e as EventArgs) WriteFile("Appl ication Starting") end sub
protected sub Application_End (ByVal Sender as Object, _ ByVal e as EventArgs) WriteFile("Appl ication Ending") end sub
protected sub Session_Start(B yVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Session_St art" + "<br/>") end sub
protected sub Session_End(ByV al Sender as Object, _ ByVal e as EventArgs) Response.Write( "Session_En d" + "<br/>") end sub
protected sub Application_Dis posed(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Di sposed" + "<br/>") end sub
protected sub Application_Err or(ByVal Sender as Object, _ ByVal e as EventArgs) dim strError as string strError = Server.GetLastE rror().ToString ()
Context.ClearEr ror()
Response.Write( "Application_Er ror" + "<br/>") Response.Write( "Error Msg: " & strError + "<br/>") end sub
protected sub Application_Beg inRequest(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Be ginRequest" + "<br/>") end sub
protected sub Application_End Request(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_En dRequest" + "<br/>") end sub
protected sub Application_Acq uireRequestStat e(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Ac quireRequestSta te" + "<br/>") end sub
protected sub Application_Aut henticateReques t(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Au thenticateReque st" + "<br/>") end sub
protected sub Application_Aut horizeRequest(B yVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Au thorizeRequest" + "<br/>") end sub
protected sub Application_Pos tRequestHandler Execute(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Po stRequestHandle rExecute" + "<br/>") end sub
protected sub Application_Pre RequestHandlerE xecute(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Pr eRequestHandler Execute" + "<br/>") end sub
protected sub Application_Pre SendRequestCont ent(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>") end sub
protected sub Application_Pre SendRequestHead ers(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>") end sub
protected sub Application_Rel easeRequestStat e(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Re leaseRequestSta te" + "<br/>") end sub
protected sub Application_Res olveRequestCach e(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Re solveRequestCac he" + "<br/>") end sub
protected sub Application_Upd ateRequestCache (ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Up dateRequestCach e" + "<br/>") end sub
sub WriteFile(strTe xt 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
Global routines should probably be placed inside their own utility class,
such as:
public sealed class Utility{
private void Utility(){}
public static void WriteLine(strin g value){
HttpContext.Cur rent.Response.W rite(value);
}
...
}
which can then be called via:
Utility.WriteLi ne("yyy");
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message
news:uv******** ******@TK2MSFTN GP14.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:ed******** ******@TK2MSFTN GP12.phx.gbl... TShad: You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message news:%2******** **********@TK2M SFTNGP09.phx.gb l... I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ ByVal e as EventArgs) WriteFile("Appl ication Starting") end sub
protected sub Application_End (ByVal Sender as Object, _ ByVal e as EventArgs) WriteFile("Appl ication Ending") end sub
protected sub Session_Start(B yVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Session_St art" + "<br/>") end sub
protected sub Session_End(ByV al Sender as Object, _ ByVal e as EventArgs) Response.Write( "Session_En d" + "<br/>") end sub
protected sub Application_Dis posed(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Di sposed" + "<br/>") end sub
protected sub Application_Err or(ByVal Sender as Object, _ ByVal e as EventArgs) dim strError as string strError = Server.GetLastE rror().ToString ()
Context.ClearEr ror()
Response.Write( "Application_Er ror" + "<br/>") Response.Write( "Error Msg: " & strError + "<br/>") end sub
protected sub Application_Beg inRequest(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Be ginRequest" + "<br/>") end sub
protected sub Application_End Request(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_En dRequest" + "<br/>") end sub
protected sub Application_Acq uireRequestStat e(ByVal Sender as
Object, _ ByVal e as EventArgs) Response.Write( "Application_Ac quireRequestSta te" + "<br/>") end sub
protected sub Application_Aut henticateReques t(ByVal Sender as
Object, _ ByVal e as EventArgs) Response.Write( "Application_Au thenticateReque st" + "<br/>") end sub
protected sub Application_Aut horizeRequest(B yVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Au thorizeRequest" + "<br/>") end sub
protected sub Application_Pos tRequestHandler Execute(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Po stRequestHandle rExecute" + "<br/>") end sub
protected sub Application_Pre RequestHandlerE xecute(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Pr eRequestHandler Execute" + "<br/>") end sub
protected sub Application_Pre SendRequestCont ent(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>") end sub
protected sub Application_Pre SendRequestHead ers(ByVal Sender as Object, _ ByVal e as EventArgs) Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>") end sub
protected sub Application_Rel easeRequestStat e(ByVal Sender as
Object, _ ByVal e as EventArgs) Response.Write( "Application_Re leaseRequestSta te" + "<br/>") end sub
protected sub Application_Res olveRequestCach e(ByVal Sender as
Object, _ ByVal e as EventArgs) Response.Write( "Application_Re solveRequestCac he" + "<br/>") end sub
protected sub Application_Upd ateRequestCache (ByVal Sender as Object,
_ ByVal e as EventArgs) Response.Write( "Application_Up dateRequestCach e" + "<br/>") end sub
sub WriteFile(strTe xt 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
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:OL******** ******@TK2MSFTN GP09.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(strin g value){ HttpContext.Cur rent.Response.W rite(value); } ... }
which can then be called via:
Utility.WriteLi ne("yyy");
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message news:uv******** ******@TK2MSFTN GP14.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:ed******** ******@TK2MSFTN GP12.phx.gbl... > TShad: > You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message > news:%2******** **********@TK2M SFTNGP09.phx.gb l... >> I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Starting") >> end sub >> >> protected sub Application_End (ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Ending") >> end sub >> >> protected sub Session_Start(B yVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_St art" + "<br/>") >> end sub >> >> protected sub Session_End(ByV al Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_En d" + "<br/>") >> end sub >> >> protected sub Application_Dis posed(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Di sposed" + "<br/>") >> end sub >> >> protected sub Application_Err or(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> dim strError as string >> strError = Server.GetLastE rror().ToString () >> >> Context.ClearEr ror() >> >> Response.Write( "Application_Er ror" + "<br/>") >> Response.Write( "Error Msg: " & strError + "<br/>") >> end sub >> >> protected sub Application_Beg inRequest(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Be ginRequest" + "<br/>") >> end sub >> >> protected sub Application_End Request(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_En dRequest" + "<br/>") >> end sub >> >> protected sub Application_Acq uireRequestStat e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Ac quireRequestSta te" + "<br/>") >> end sub >> >> protected sub Application_Aut henticateReques t(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thenticateReque st" + "<br/>") >> end sub >> >> protected sub Application_Aut horizeRequest(B yVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thorizeRequest" + "<br/>") >> end sub >> >> protected sub Application_Pos tRequestHandler Execute(ByVal Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Po stRequestHandle rExecute" + >> "<br/>") >> end sub >> >> protected sub Application_Pre RequestHandlerE xecute(ByVal Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eRequestHandler Execute" + "<br/>") >> end sub >> >> protected sub Application_Pre SendRequestCont ent(ByVal Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>") >> end sub >> >> protected sub Application_Pre SendRequestHead ers(ByVal Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>") >> end sub >> >> protected sub Application_Rel easeRequestStat e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re leaseRequestSta te" + "<br/>") >> end sub >> >> protected sub Application_Res olveRequestCach e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re solveRequestCac he" + "<br/>") >> end sub >> >> protected sub Application_Upd ateRequestCache (ByVal Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Up dateRequestCach e" + "<br/>") >> end sub >> >> sub WriteFile(strTe xt 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 >> >> >> > >
> 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**********@f tsolutions.com> wrote in message
news:eY******** ******@TK2MSFTN GP15.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:OL******** ******@TK2MSFTN GP09.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(strin g value){ HttpContext.Cur rent.Response.W rite(value); } ... }
which can then be called via:
Utility.WriteLi ne("yyy");
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message news:uv******** ******@TK2MSFTN GP14.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:ed******** ******@TK2MSFTN GP12.phx.gbl... > TShad: > You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message > news:%2******** **********@TK2M SFTNGP09.phx.gb l... >> I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Starting") >> end sub >> >> protected sub Application_End (ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Ending") >> end sub >> >> protected sub Session_Start(B yVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_St art" + "<br/>") >> end sub >> >> protected sub Session_End(ByV al Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_En d" + "<br/>") >> end sub >> >> protected sub Application_Dis posed(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Di sposed" + "<br/>") >> end sub >> >> protected sub Application_Err or(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> dim strError as string >> strError = Server.GetLastE rror().ToString () >> >> Context.ClearEr ror() >> >> Response.Write( "Application_Er ror" + "<br/>") >> Response.Write( "Error Msg: " & strError + "<br/>") >> end sub >> >> protected sub Application_Beg inRequest(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Be ginRequest" + "<br/>") >> end sub >> >> protected sub Application_End Request(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_En dRequest" + "<br/>") >> end sub >> >> protected sub Application_Acq uireRequestStat e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Ac quireRequestSta te" + "<br/>") >> end sub >> >> protected sub Application_Aut henticateReques t(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thenticateReque st" + "<br/>") >> end sub >> >> protected sub Application_Aut horizeRequest(B yVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thorizeRequest" + "<br/>") >> end sub >> >> protected sub Application_Pos tRequestHandler Execute(ByVal Sender >> as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Po stRequestHandle rExecute" + >> "<br/>") >> end sub >> >> protected sub Application_Pre RequestHandlerE xecute(ByVal Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eRequestHandler Execute" + >> "<br/>") >> end sub >> >> protected sub Application_Pre SendRequestCont ent(ByVal Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>") >> end sub >> >> protected sub Application_Pre SendRequestHead ers(ByVal Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>") >> end sub >> >> protected sub Application_Rel easeRequestStat e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re leaseRequestSta te" + "<br/>") >> end sub >> >> protected sub Application_Res olveRequestCach e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re solveRequestCac he" + "<br/>") >> end sub >> >> protected sub Application_Upd ateRequestCache (ByVal Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Up dateRequestCach e" + "<br/>") >> end sub >> >> sub WriteFile(strTe xt 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 >> >> >> > >
On 23 Feb 2005, "tshad" <ts**********@f tsolutions.com> postulated in
news:eY******** ******@TK2MSFTN GP15.phx.gbl: "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME
net> wrote in message news:OL******** ******@TK2MSFTN GP09.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(strin g value){ HttpContext.Cur rent.Response.W rite(value); } ... }
which can then be called via:
Utility.WriteLi ne("yyy");
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message news:uv******** ******@TK2MSFTN GP14.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO .
ANDME net> wrote in message news:ed******** ******@TK2MSFTN GP12.phx.gbl... > TShad: > You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message > news:%2******** **********@TK2M SFTNGP09.phx.gb l... >> I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Starting") >> end sub >> >> protected sub Application_End (ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Ending") >> end sub >> >> protected sub Session_Start(B yVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_St art" + "<br/>") >> end sub >> >> protected sub Session_End(ByV al Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_En d" + "<br/>") >> end sub >> >> protected sub Application_Dis posed(ByVal Sender as Object,
_ >> ByVal e as EventArgs) >> Response.Write( "Application_Di sposed" + "<br/>") >> end sub >> >> protected sub Application_Err or(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> dim strError as string >> strError = Server.GetLastE rror().ToString () >> >> Context.ClearEr ror() >> >> Response.Write( "Application_Er ror" + "<br/>") >> Response.Write( "Error Msg: " & strError + "<br/>") >> end sub >> >> protected sub Application_Beg inRequest(ByVal Sender as
Object, _ >> ByVal e as
EventArgs) >> Response.Write( "Application_Be ginRequest" + "<br/>") >> end sub >> >> protected sub Application_End Request(ByVal Sender as
Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_En dRequest" + "<br/>") >> end sub >> >> protected sub Application_Acq uireRequestStat e(ByVal Sender
as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Ac quireRequestSta te" +
"<br/>") >> end sub >> >> protected sub Application_Aut henticateReques t(ByVal Sender
as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thenticateReque st" +
"<br/>") >> end sub >> >> protected sub Application_Aut horizeRequest(B yVal Sender as
Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thorizeRequest" + "<br/>") >> end sub >> >> protected sub Application_Pos tRequestHandler Execute(ByVal
Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Po stRequestHandle rExecute" + >> "<br/>") >> end sub >> >> protected sub Application_Pre RequestHandlerE xecute(ByVal
Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eRequestHandler Execute" +
"<br/>") >> end sub >> >> protected sub Application_Pre SendRequestCont ent(ByVal
Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestCon tent" +
"<br/>") >> end sub >> >> protected sub Application_Pre SendRequestHead ers(ByVal
Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestHea ders" +
"<br/>") >> end sub >> >> protected sub Application_Rel easeRequestStat e(ByVal Sender
as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re leaseRequestSta te" +
"<br/>") >> end sub >> >> protected sub Application_Res olveRequestCach e(ByVal Sender
as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re solveRequestCac he" +
"<br/>") >> end sub >> >> protected sub Application_Upd ateRequestCache (ByVal Sender
as >> Object,
_ >> ByVal e as EventArgs) >> Response.Write( "Application_Up dateRequestCach e" +
"<br/>") >> end sub >> >> sub WriteFile(strTe xt 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
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:%2******** ********@TK2MSF TNGP09.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**********@f tsolutions.com> wrote in message news:eY******** ******@TK2MSFTN GP15.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:OL******** ******@TK2MSFTN GP09.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(strin g value){ HttpContext.Cur rent.Response.W rite(value); } ... }
which can then be called via:
Utility.WriteLi ne("yyy");
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message news:uv******** ******@TK2MSFTN GP14.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:ed******** ******@TK2MSFTN GP12.phx.gbl... > TShad: > You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message > news:%2******** **********@TK2M SFTNGP09.phx.gb l... >> I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Starting") >> end sub >> >> protected sub Application_End (ByVal Sender as Object, _ >> ByVal e as EventArgs) >> WriteFile("Appl ication Ending") >> end sub >> >> protected sub Session_Start(B yVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_St art" + "<br/>") >> end sub >> >> protected sub Session_End(ByV al Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Session_En d" + "<br/>") >> end sub >> >> protected sub Application_Dis posed(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Di sposed" + "<br/>") >> end sub >> >> protected sub Application_Err or(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> dim strError as string >> strError = Server.GetLastE rror().ToString () >> >> Context.ClearEr ror() >> >> Response.Write( "Application_Er ror" + "<br/>") >> Response.Write( "Error Msg: " & strError + "<br/>") >> end sub >> >> protected sub Application_Beg inRequest(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Be ginRequest" + "<br/>") >> end sub >> >> protected sub Application_End Request(ByVal Sender as Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_En dRequest" + "<br/>") >> end sub >> >> protected sub Application_Acq uireRequestStat e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Ac quireRequestSta te" + "<br/>") >> end sub >> >> protected sub Application_Aut henticateReques t(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thenticateReque st" + "<br/>") >> end sub >> >> protected sub Application_Aut horizeRequest(B yVal Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Au thorizeRequest" + "<br/>") >> end sub >> >> protected sub Application_Pos tRequestHandler Execute(ByVal Sender >> as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Po stRequestHandle rExecute" + >> "<br/>") >> end sub >> >> protected sub Application_Pre RequestHandlerE xecute(ByVal Sender >> as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eRequestHandler Execute" + >> "<br/>") >> end sub >> >> protected sub Application_Pre SendRequestCont ent(ByVal Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>") >> end sub >> >> protected sub Application_Pre SendRequestHead ers(ByVal Sender as >> Object, > _ >> ByVal e as EventArgs) >> Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>") >> end sub >> >> protected sub Application_Rel easeRequestStat e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re leaseRequestSta te" + "<br/>") >> end sub >> >> protected sub Application_Res olveRequestCach e(ByVal Sender as Object, >> _ >> ByVal e as EventArgs) >> Response.Write( "Application_Re solveRequestCac he" + "<br/>") >> end sub >> >> protected sub Application_Upd ateRequestCache (ByVal Sender as >> Object, _ >> ByVal e as EventArgs) >> Response.Write( "Application_Up dateRequestCach e" + "<br/>") >> end sub >> >> sub WriteFile(strTe xt 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.
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
> 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**********@f tsolutions.com> wrote in message
news:Ou******** ******@tk2msftn gp13.phx.gbl... "Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message news:%2******** ********@TK2MSF TNGP09.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**********@f tsolutions.com> wrote in message news:eY******** ******@TK2MSFTN GP15.phx.gbl... "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:OL******** ******@TK2MSFTN GP09.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(strin g value){ HttpContext.Cur rent.Response.W rite(value); } ... }
which can then be called via:
Utility.WriteLi ne("yyy");
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/
"tshad" <ts**********@f tsolutions.com> wrote in message news:uv******** ******@TK2MSFTN GP14.phx.gbl... > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME > net> > wrote in message news:ed******** ******@TK2MSFTN GP12.phx.gbl... > > TShad: > > You can't Response.Write within Application_Sta rt...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**********@f tsolutions.com> wrote in message > > news:%2******** **********@TK2M SFTNGP09.phx.gb l... > >> I have an example I copied from "programmin g 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_Sta rt(ByVal Sender as Object, _ > >> ByVal e as EventArgs) > >> WriteFile("Appl ication Starting") > >> end sub > >> > >> protected sub Application_End (ByVal Sender as Object, _ > >> ByVal e as EventArgs) > >> WriteFile("Appl ication Ending") > >> end sub > >> > >> protected sub Session_Start(B yVal Sender as Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Session_St art" + "<br/>") > >> end sub > >> > >> protected sub Session_End(ByV al Sender as Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Session_En d" + "<br/>") > >> end sub > >> > >> protected sub Application_Dis posed(ByVal Sender as Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Di sposed" + "<br/>") > >> end sub > >> > >> protected sub Application_Err or(ByVal Sender as Object, _ > >> ByVal e as EventArgs) > >> dim strError as string > >> strError = Server.GetLastE rror().ToString () > >> > >> Context.ClearEr ror() > >> > >> Response.Write( "Application_Er ror" + "<br/>") > >> Response.Write( "Error Msg: " & strError + "<br/>") > >> end sub > >> > >> protected sub Application_Beg inRequest(ByVal Sender as Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Be ginRequest" + "<br/>") > >> end sub > >> > >> protected sub Application_End Request(ByVal Sender as Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_En dRequest" + "<br/>") > >> end sub > >> > >> protected sub Application_Acq uireRequestStat e(ByVal Sender as Object, > >> _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Ac quireRequestSta te" + "<br/>") > >> end sub > >> > >> protected sub Application_Aut henticateReques t(ByVal Sender as Object, > >> _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Au thenticateReque st" + "<br/>") > >> end sub > >> > >> protected sub Application_Aut horizeRequest(B yVal Sender as > >> Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Au thorizeRequest" + "<br/>") > >> end sub > >> > >> protected sub Application_Pos tRequestHandler Execute(ByVal Sender > >> as > >> Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Po stRequestHandle rExecute" + > >> "<br/>") > >> end sub > >> > >> protected sub Application_Pre RequestHandlerE xecute(ByVal Sender > >> as > >> Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Pr eRequestHandler Execute" + > >> "<br/>") > >> end sub > >> > >> protected sub Application_Pre SendRequestCont ent(ByVal Sender as > >> Object, > > _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Pr eSendRequestCon tent" + "<br/>") > >> end sub > >> > >> protected sub Application_Pre SendRequestHead ers(ByVal Sender as > >> Object, > > _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Pr eSendRequestHea ders" + "<br/>") > >> end sub > >> > >> protected sub Application_Rel easeRequestStat e(ByVal Sender as Object, > >> _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Re leaseRequestSta te" + "<br/>") > >> end sub > >> > >> protected sub Application_Res olveRequestCach e(ByVal Sender as Object, > >> _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Re solveRequestCac he" + "<br/>") > >> end sub > >> > >> protected sub Application_Upd ateRequestCache (ByVal Sender as > >> Object, _ > >> ByVal e as EventArgs) > >> Response.Write( "Application_Up dateRequestCach e" + "<br/>") > >> end sub > >> > >> sub WriteFile(strTe xt 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 > >> > >> > >> > > > > > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 any of the
response.write lines from inside the sub.
*******************************************
<%@ Application Language="VB" %>
<script runat="server">
|
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 file, and what would I
do to access it? (I am using VB.NET for my code) Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/
|
by: ad |
last post by:
The Global.asax is code-inside with default.
How to change Global.asax to code-behind?
|
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 do I ensure that changes made to the "Global.asax.vb" file are
immediately reflected in the "Global.asax" file? After I change to the
"Global.asax.vb" file, the "Global.asax" file date modified does not change
and I do not see the updated values...
|
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.
<%@ Application Language="C#" %>
<script runat="server">
| |
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 and handle them at the same time - in parallel.
The funny thing is that the behaviour of the implementation I created
depends on the existence of Global.asax in the Web application.
Here is the source of the page that handles the regular GET...
|
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., global.asax.cs; So, I deleted the
existing global.asax file (there was nothing important in it yet), and went
to add a new one through VS2005. I chose the "Global Application Class"
(Global.asax) item from the list of new items. The "Place code in...
|
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 created a CS file in App_Code
folder named Global.asax.cs:
public class Global : System.Web.HttpApplication {
void Application_OnError(object sender, EventArgs e) {
// my own complex error handling logic
}
|
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 in the Bin folder
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |