J
JustinCarmony
Hi,
I'm a PHP programmer who has been hired by a company to do web
applications, but they want me to use ASP .NET. For the most part, the
transition has been relatively smooth. However, I have a question:
In PHP, I would create a class that I called DBContol that would be the
intermediary for all communications between my web application and
Database. I would execute a command something like this:
<?
// This
$GLOBALS["mainDB"] = new DBControl("DatabaseName");
// or I would store it in the session
$_SESSION["mainDB"] = new DBControl("DatabaseName);
// Then I would be able to execute commands something like this:
$_SESSION["mainDB"]->query($queryString);
?>
Now, in ASP .NET I know there is a Global.asax file that you create
that is the "root" of the application and is the very first executed,
depending on what EventHandler you use. You also use an <object> tag to
declare objects used across the application.
The problem is, I can't really get this to work. So here is my
question:
How can I create an instance of a class in my application that can
access that object where ever needed in the code, how do I access it
and run it's methods, and make sure that its a sound and secure way of
doing this. I've looked for tutorials, and they all talk about storing
variables globally, but I need to access this instance of a class no
matter where in the code.
Any suggestions? Thanks in advance for any replies.
I'm a PHP programmer who has been hired by a company to do web
applications, but they want me to use ASP .NET. For the most part, the
transition has been relatively smooth. However, I have a question:
In PHP, I would create a class that I called DBContol that would be the
intermediary for all communications between my web application and
Database. I would execute a command something like this:
<?
// This
$GLOBALS["mainDB"] = new DBControl("DatabaseName");
// or I would store it in the session
$_SESSION["mainDB"] = new DBControl("DatabaseName);
// Then I would be able to execute commands something like this:
$_SESSION["mainDB"]->query($queryString);
?>
Now, in ASP .NET I know there is a Global.asax file that you create
that is the "root" of the application and is the very first executed,
depending on what EventHandler you use. You also use an <object> tag to
declare objects used across the application.
The problem is, I can't really get this to work. So here is my
question:
How can I create an instance of a class in my application that can
access that object where ever needed in the code, how do I access it
and run it's methods, and make sure that its a sound and secure way of
doing this. I've looked for tutorials, and they all talk about storing
variables globally, but I need to access this instance of a class no
matter where in the code.
Any suggestions? Thanks in advance for any replies.