Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Sep 06, 2010 12:07 AM by erik5388
Aug 11, 2010 11:17 PM|LINK
Unfortunately, no. The "as DAL" in there will blow up without a using at the top of the page. The first approach I suggested should work without a using though.
Sep 03, 2010 02:26 PM|LINK
Hey... Interesting thing I stumbled on...
I created a Global.cs file and placed it in my app_code directory. I assigned my instances and variables as public static members...
public static class Global
public static Exception ex = null;
public static DAL dal = new DAL();
public static string ConnectionString = ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
public static void SetConnectionString()
dal.ConnectionString = ConnectionString;
For the sake of keeping my connection string available on every page I called the SetConnectionString (above) function,
Becuase of the public static members in Global.cs I can call my instanced dal without creating a new instance of dal (this was done in Global.cs)
void myfunction(Global.something, out Global.ex);
By first created a public static class I can use it throughout my project...
Sep 03, 2010 04:32 PM|LINK
I am almost completely sure that won't scale and you'll have issues when requests start coming in fast and each request is hitting the same variable. Your object should really be instantiated per request (stuffed in Context.Items or something that lives
for the life of the request)...for now.
We're finishing up new simplified state management for the next release that will make what you're trying to do, much easier. Basically, you'll be able to say Page.dal = new DAL(); and set all your initial properties you need in _Init.cshtml, then in any
web page you can access Page.dal. Simple. :)
Sep 06, 2010 12:07 AM|LINK
Darn, I thought I found something cool ><
What kind of issues will accur when requests come in faster?
I can revert back to the Context.Items as you mentioned earlier and thats fine...
However.... When does the next release come out?? heheh (= !?!?!?