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

We are a .NET shop (usually ASP.NET MVC) and we have a customer requirement
Usually when I execute a stored proc from C# (ASP.NET 3.5), I have to
I have to create a web form in ASP.NET. this is my HTML: <form
I usually create a gridview based on data so it will have the rows
In android, I usually use MyAdapter extends ArrayAdapter to create view for the ListView
i am using asp.net framework 4 and i have created brand new project and
I usually create usercontrol which is referring javascript file/block. For example, I have a
I have 5 ASP.NET Web Applications that I need to distribute to client machines.
In .Net I usually create a separate class library and reference it in my
We have an ASP.NET 2.0 application that uses Enterprise Library Data Access Application Block

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.