Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 321489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:51:01+00:00 2026-05-12T08:51:01+00:00

I usually create ASP.NET websites and have a few classes I use, mainly a

  • 0

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 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T08:51:02+00:00Added an answer on May 12, 2026 at 8:51 am

    For the base class You can create ApplicationControler
    Somethig like :

    namespace YourApplication.Controllers
    {
        public abstract class ApplicationController : Controller
        {
            public ApplicationController()
            {
                using(ApplicationDataContext menu = new ApplicationDataContext())
                {
                    // loading data for menu control
                    MenuRepository myMenu = new MenuRepository();
                    ViewData["menu"] = myMenu.MenuList();
                }
            }
        }
    }
    

    And then you can just extend it from any controler
    like this:

    namespace YourApplication.Controllers
    {
        public class DefaultController : ApplicationController
        {
            public ActionResult Index()
            {
                return View();
            }
        }
    }
    

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Usually when I execute a stored proc from C# (ASP.NET 3.5), I have to
Usually when defining a DAO, you would have a setter for the datasource on
I have this sort of format asp.net MVC View -> Service Layer -> Repository.
In order to fully use LinqToSql in an ASP.net 3.5 application, it is necessary
I have a very simple ASP.NET web application created under Visual Studio 2008 (SP1),
I would like to consume WCF service (created by ASP .NET) with PHP. I
I usually create my SQL tables and stored procedures by writing a script inside
Hey I usually run into a situation where I will create a class that
Usually, we install VS.NET on our production server, to solve problems easily with our
Usually, when using Windows Authentication, the software (eg Internet Explorer) tries to use Windows

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.