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

ASP.NET Global object created twice?

P: n/a

the constructor definition in my Global.asax.cs file contains (among other
things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the
Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR
Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
When I tried this, the double construction only happens on the start up of
the application. After that I don't any conctruction ever again. How much of
a problem is this?
"John Ruiz" <no******@provided.com> wrote in message
news:eq*************@TK2MSFTNGP11.phx.gbl...

the constructor definition in my Global.asax.cs file contains (among other
things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the
Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR

Nov 17 '05 #2

P: n/a

My Global class has a Dumb object as an attribute. Within
Application_Start(), this object gets instantiated and initialized (
myDumbObject = new Dumb(); ).

But if the Global object is getting created twice, then when I go to use my
Dumb object, I get an error because the Dumb object hasn't been instantiated
in the second Global object.

I consider this a problem, but maybe you do not. "How much" is inherently
relative. At any rate, I "very much" appreciate your time. :-)

~ jR
"NoOne" <No@Where.com> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl...
When I tried this, the double construction only happens on the start up of
the application. After that I don't any conctruction ever again. How much of
a problem is this?
"John Ruiz" <no******@provided.com> wrote in message
news:eq*************@TK2MSFTNGP11.phx.gbl...

the constructor definition in my Global.asax.cs file contains (among other
things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the
Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR


Nov 17 '05 #3

P: n/a
JD
Well you realy didn't explain yourself in your first post and tell us why
this was a problem

After the initial dumb object creation, can you put the dumb object into the
application cache, and reference it from there on subsequent requests?

"John Ruiz" <no******@provided.com> wrote in message
news:eE**************@tk2msftngp13.phx.gbl...

My Global class has a Dumb object as an attribute. Within
Application_Start(), this object gets instantiated and initialized (
myDumbObject = new Dumb(); ).

But if the Global object is getting created twice, then when I go to use my Dumb object, I get an error because the Dumb object hasn't been instantiated in the second Global object.

I consider this a problem, but maybe you do not. "How much" is inherently
relative. At any rate, I "very much" appreciate your time. :-)

~ jR
"NoOne" <No@Where.com> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl...
When I tried this, the double construction only happens on the start up of
the application. After that I don't any conctruction ever again. How much of a problem is this?
"John Ruiz" <no******@provided.com> wrote in message
news:eq*************@TK2MSFTNGP11.phx.gbl...

the constructor definition in my Global.asax.cs file contains (among other things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the
Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR


Nov 17 '05 #4

P: n/a
Hello

ASP.NET uses one Global class instance to serve a single request. After
requests ends the instance is recycled for use by later request. ASP.NET can
create many instances to handle simultaneous requests. To solve you problem
I think making the dumb object static will solve it.

Best regards,

Sherif

"John Ruiz" <no******@provided.com> wrote in message
news:eE**************@tk2msftngp13.phx.gbl...

My Global class has a Dumb object as an attribute. Within
Application_Start(), this object gets instantiated and initialized (
myDumbObject = new Dumb(); ).

But if the Global object is getting created twice, then when I go to use my Dumb object, I get an error because the Dumb object hasn't been instantiated in the second Global object.

I consider this a problem, but maybe you do not. "How much" is inherently
relative. At any rate, I "very much" appreciate your time. :-)

~ jR
"NoOne" <No@Where.com> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl...
When I tried this, the double construction only happens on the start up of
the application. After that I don't any conctruction ever again. How much of a problem is this?
"John Ruiz" <no******@provided.com> wrote in message
news:eq*************@TK2MSFTNGP11.phx.gbl...

the constructor definition in my Global.asax.cs file contains (among other things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the
Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR


Nov 17 '05 #5

P: n/a
Hey - where do you get off calling my objects dumb?? Hahaha.

Thanks for the suggestion - I'll try this out and see if anyone around here
comes down on me for it.

~ jR
"JD" <no@where.com> wrote in message
news:QLWpb.109189$e01.374913@attbi_s02...
Well you realy didn't explain yourself in your first post and tell us why
this was a problem

After the initial dumb object creation, can you put the dumb object into the
application cache, and reference it from there on subsequent requests?

"John Ruiz" <no******@provided.com> wrote in message
news:eE**************@tk2msftngp13.phx.gbl...

My Global class has a Dumb object as an attribute. Within
Application_Start(), this object gets instantiated and initialized (
myDumbObject = new Dumb(); ).

But if the Global object is getting created twice, then when I go to use my Dumb object, I get an error because the Dumb object hasn't been instantiated in the second Global object.

I consider this a problem, but maybe you do not. "How much" is inherently
relative. At any rate, I "very much" appreciate your time. :-)

~ jR
"NoOne" <No@Where.com> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl...
When I tried this, the double construction only happens on the start up of
the application. After that I don't any conctruction ever again. How much of a problem is this?
"John Ruiz" <no******@provided.com> wrote in message
news:eq*************@TK2MSFTNGP11.phx.gbl...

the constructor definition in my Global.asax.cs file contains (among other things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the
Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR



Nov 17 '05 #6

P: n/a
Hey - who said you could go around calling my objects dumb?? hahaha.

Not sure if circumstances will allow me to arbitrarily turn the dumb object
static, but I will look into this possibility also.

Thanks!
~ jR

"Sherif ElMetainy" <el*************@wayout.net.NOSPAM> wrote in message
news:uc**************@TK2MSFTNGP09.phx.gbl...
Hello

ASP.NET uses one Global class instance to serve a single request. After
requests ends the instance is recycled for use by later request. ASP.NET can
create many instances to handle simultaneous requests. To solve you problem
I think making the dumb object static will solve it.

Best regards,

Sherif

"John Ruiz" <no******@provided.com> wrote in message
news:eE**************@tk2msftngp13.phx.gbl...

My Global class has a Dumb object as an attribute. Within
Application_Start(), this object gets instantiated and initialized (
myDumbObject = new Dumb(); ).

But if the Global object is getting created twice, then when I go to use my Dumb object, I get an error because the Dumb object hasn't been instantiated in the second Global object.

I consider this a problem, but maybe you do not. "How much" is inherently
relative. At any rate, I "very much" appreciate your time. :-)

~ jR
"NoOne" <No@Where.com> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl...
When I tried this, the double construction only happens on the start up of
the application. After that I don't any conctruction ever again. How much of a problem is this?
"John Ruiz" <no******@provided.com> wrote in message
news:eq*************@TK2MSFTNGP11.phx.gbl...

the constructor definition in my Global.asax.cs file contains (among other things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the
Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR



Nov 17 '05 #7

P: n/a
I was actually laughing to myself when I wrote that message...

"John Ruiz" <no******@provided.com> wrote in message
news:u4**************@tk2msftngp13.phx.gbl...
Hey - where do you get off calling my objects dumb?? Hahaha.

Thanks for the suggestion - I'll try this out and see if anyone around here comes down on me for it.

~ jR
"JD" <no@where.com> wrote in message
news:QLWpb.109189$e01.374913@attbi_s02...
Well you realy didn't explain yourself in your first post and tell us why
this was a problem

After the initial dumb object creation, can you put the dumb object into the application cache, and reference it from there on subsequent requests?

"John Ruiz" <no******@provided.com> wrote in message
news:eE**************@tk2msftngp13.phx.gbl...

My Global class has a Dumb object as an attribute. Within
Application_Start(), this object gets instantiated and initialized (
myDumbObject = new Dumb(); ).

But if the Global object is getting created twice, then when I go to use my
Dumb object, I get an error because the Dumb object hasn't been

instantiated
in the second Global object.

I consider this a problem, but maybe you do not. "How much" is inherently
relative. At any rate, I "very much" appreciate your time. :-)

~ jR
"NoOne" <No@Where.com> wrote in message
news:#I**************@TK2MSFTNGP10.phx.gbl...
When I tried this, the double construction only happens on the start up of the application. After that I don't any conctruction ever again. How

much of
a problem is this?
"John Ruiz" <no******@provided.com> wrote in message
news:eq*************@TK2MSFTNGP11.phx.gbl...

the constructor definition in my Global.asax.cs file contains (among

other things) the following line:

System.Diagnostics.Debug.WriteLine( "Global Constructor ran." );

when I run my web application via the debug menu of VS.NET, my console
prints out the above log message... twice! why does ASP.NET create the Global object twice, how can I get it to not do this and if it is not
possible, what are viable work arounds?

thankful and stuff,
~ jR



Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.