Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access Global.asax static members?

If we declare a static variable in Global.asax then how to access it inside an ASP.NET page ?

<script runat=server">

   public static object myObject = new MyClass();

   // Application_Start() and other stuff goes here.

</script>

And, is this a good idea for storing a global object (same instance for all requests) ?

like image 350
Xaqron Avatar asked Oct 13 '22 18:10

Xaqron


1 Answers

myObject should be available to all the methods in global.asax and inside your ASP.NET pages using

Global.myObject
like image 199
phillip Avatar answered Oct 19 '22 17:10

phillip