Re: Global's non static methods
From: William F. Robertson, Jr. (wfrobertson_at_kpmg.com)
Date: 05/05/04
- Next message: Curt_C [MVP]: "Re: Custom validation"
- Previous message: Chris Curvey: "enabling asp.net on iis 5.1"
- In reply to: Scott Allen: "Re: Global's non static methods"
- Next in thread: Scott Allen: "Re: Global's non static methods"
- Reply: Scott Allen: "Re: Global's non static methods"
- Reply: A.M: "Re: Global's non static methods"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 5 May 2004 12:51:33 -0500
You are both incorrect, you can instantiate an instance of Global.
(How else does asp.net work if it is impossible to instantiate an Global to
process each request?)
But the second part of Scott's reply is correct. I didn't even realize
there was an ApplicationInstance property of the Context.
Alan, Is there any reason you don't want the property to be static?
bill
"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:1l7i90pspdmtkolkbtgj41httqcbfmb3lg@4ax.com...
> Hi Alan,
>
> On Wed, 5 May 2004 12:03:00 -0400, "A.M" <IHateSpam@sapm123.com>
> wrote:
>
>
> >I don't think we can create our own instance of Global object.
> >
>
> That's correct.
>
> >I am sure that ASP.NET framework creates the instance for us.
> >Based on what microsoft mentioned in kb#312607, I should be able to have
> >access to that instance by using Page.ApplicationInstance property, But
it
> >doesn't work for me. That means I don't have access to non-static
members!
> >and they don't appear in IDE inlisense
> >
>
> I think that is a bug in the documentation. It should probably read
> "every page includes a strongly-typed Context property of type
> "HttpContext". To get to the instance of the Global class associated
> with your request, you can do:
>
> Global g = Context.ApplicationInstance as Global;
> if(g != null)
> {
> // party on g
> }
>
> Hope that helps.
>
> --
> Scott
> http://www.OdeToCode.com
>
>
- Next message: Curt_C [MVP]: "Re: Custom validation"
- Previous message: Chris Curvey: "enabling asp.net on iis 5.1"
- In reply to: Scott Allen: "Re: Global's non static methods"
- Next in thread: Scott Allen: "Re: Global's non static methods"
- Reply: Scott Allen: "Re: Global's non static methods"
- Reply: A.M: "Re: Global's non static methods"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|