global.asax classname

  • Thread starter Thread starter noname
  • Start date Start date
N

noname

i have the following in global.asax:
<%@ Application Codebehind="Global.asax.cs" Inherits="Foo.Global"
Classname="AppClass" %>

but wherever i use AppClass.foo() i get the compiler error:
The type or namespace name 'AppClass' could not be found (are you missing a
using directive or an assembly reference?)

am i missing something?
thanks.
 
This is my guess (* guessing is required without knowing more about your
global.asax.cs implementation).

When you create a Global.asax file with code behind you are actually
defining what will be a super class of the actual runtime class ASP.NET
uses. This is the same as what happens when you are dealing with aspx
files.

For example:

By default the code behind class for Global.asax is called "Global". It is
a subclass of HttpApplication. Your definition of global.asax will probably
cause ASP.NET to create a new class called AppClass that is a subclass of
Global. Like this:

HttpApplication
+-- Global
+-- AppClass

I have a bit of a problem with your Application directive though because the
Framework 1.1 documentation I have doesn't have a Classname attribute.
Assuming that is not your problem your problem probably has to do with your
use of the class AppClass. How exactly are you refering to it? Do you have
all your code in the code behind of the class Global? You probably should
have. It is difficult to know what your problem is exactly without knowing
a bit more.

Generally though, the class Global, which by default is the subclass of
HttpApplication that you can use to implement your subclass behaviour is
where you should be doing all your overriding of HttpApplication methods and
adding your own methods and properties. You probably shouldn't be calling
AppClass.foo() either because it doesn't exist or is not visible to the
caller.

My comments probably aren't very helpful but I'm sure the solution would be
clear if you could provide a bit more detail ...

Graham.
 
Back
Top