I usually create ASP.NET websites and have a few classes I use, mainly a BaseClass. Normally I would change
public partial class _default : Page
to
public partial class _default : BaseClass
with a using at the top of the namespace name. However I don’t seem to be able to do this in MVC. How do I get my BaseClass or any other class into my MVC page?
The reason I ask is that I have a class called errors, I usually have this in my global.asax file:
void Application_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
namespace.errors.WriteError(Request.Url.ToString(), objErr.Message);
}
But I seem unable to do this, even with a shared namespace across the whole site
It is most probable that this question is lame but whatever 🙂
For the base class You can create ApplicationControler
Somethig like :
And then you can just extend it from any controler
like this:
Notice in my example in application controler I am loading view that I am gonna display on every single page, and you can load anything you want, anything that you need often or always. Thats pretty much your base class.