Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET Global object created twice?

Reply
Thread Tools

ASP.NET Global object created twice?

 
 
John Ruiz
Guest
Posts: n/a
 
      11-04-2003

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


 
Reply With Quote
 
 
 
 
NoOne
Guest
Posts: n/a
 
      11-04-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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
>
>



 
Reply With Quote
 
 
 
 
John Ruiz
Guest
Posts: n/a
 
      11-04-2003

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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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
>
>




 
Reply With Quote
 
JD
Guest
Posts: n/a
 
      11-04-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > 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
> >
> >

>
>
>



 
Reply With Quote
 
Sherif ElMetainy
Guest
Posts: n/a
 
      11-05-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > 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
> >
> >

>
>
>



 
Reply With Quote
 
John Ruiz
Guest
Posts: n/a
 
      11-05-2003
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" <(E-Mail Removed)> 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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > 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
> >
> >

>
>
>




 
Reply With Quote
 
John Ruiz
Guest
Posts: n/a
 
      11-05-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > 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
> >
> >

>
>
>




 
Reply With Quote
 
NoOne
Guest
Posts: n/a
 
      11-05-2003
I was actually laughing to myself when I wrote that message...

"John Ruiz" <(E-Mail Removed)> wrote in message
news:u4yU#(E-Mail Removed)...
> 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" <(E-Mail Removed)> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> >
> > 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" <(E-Mail Removed)> wrote in message
> > news:#(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > >
> > > 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
> > >
> > >

> >
> >
> >

>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Are global functions methods of the global object? User1014 Javascript 3 12-01-2006 01:02 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 1 10-25-2006 06:50 PM
FWSM/PIX and Dynamic PAT using global IP range vs. global interface vs. global IP Hoffa Cisco 0 10-25-2006 01:04 PM
Object creation - Do we really need to create a parent for a derieved object - can't the base object just point to an already created base object jon wayne C++ 9 09-22-2005 02:06 AM
Created object on stack and then returned this object to caller. Item deleted but still there?? opistobranchia C++ 1 08-14-2005 07:51 PM



Advertisments