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

  • Home
  • SEARCH
  • 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 568609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:12:24+00:00 2026-05-13T13:12:24+00:00

Specifically, does a controller class name have to have the Controller suffix, and can

  • 0

Specifically, does a controller class name have to have the Controller suffix, and can you change the folder structure in your project if you want to, without breaking things?

Are there other conventions that can be overridden, and how?

  • 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-13T13:12:24+00:00Added an answer on May 13, 2026 at 1:12 pm

    Most of the conventions are malleable provided you know how the framework operates. Let’s tackle two of the biggest conventions:

    1. the “{controller}/{action}/” magic keywords for instantiating controllers from a route

    2. the way the framework searches for Views first in the controller directory, and then in the Shared directory.

    Every route that you create is associated with an instance of an MvcRouteHandler object by default. When the route is matched, that handler is invoked to deal with the incoming request. Here’s what the MvcHandler’s ProcessRequest looks like:

    protected internal virtual void ProcessRequest(HttpContextBase httpContext)
    {
        this.AddVersionHeader(httpContext);
        string requiredString = this.RequestContext.RouteData.GetRequiredString("controller");
        IControllerFactory controllerFactory = this.ControllerBuilder.GetControllerFactory();
        IController controller = controllerFactory.CreateController(this.RequestContext, requiredString);
        if (controller == null)
        {
            throw new InvalidOperationException(string.Format(CultureInfo.CurrentUICulture, MvcResources.ControllerBuilder_FactoryReturnedNull, new object[] { controllerFactory.GetType(), requiredString }));
        }
        try
        {
            controller.Execute(this.RequestContext);
        }
        finally
        {
            controllerFactory.ReleaseController(controller);
        }
    }
    

    Notice the hardcoded string “controller”. Well, you can replace this handler for any route you’d like if you want to code your own controller-finding logic. Simply do something like this (shameless blog plug):

    routes.Add("ImagesRoute",
                     new Route("graphics/{filename}", new ImageRouteHandler()));
    

    Now when the route is matched, it invokes your own logic, and you can do whatever you please. Incidentally, the reflection that is used to find the XXXXController class with the “Controller” suffix is part of the DefaultControllerFactory object, invoked in the handler above, and this factory is replaceable.

    So, controller picking is one convention that’s overridable. What about when it looks for Views when you do a “return View()” from any controller method? Well here’s the constructor for the WebFormViewEngine, the default view engine of the framework:

    public WebFormViewEngine()
    {
        base.MasterLocationFormats = new string[] { "~/Views/{1}/{0}.master", "~/Views/Shared/{0}.master" };
        base.ViewLocationFormats = new string[] { "~/Views/{1}/{0}.aspx", "~/Views/{1}/{0}.ascx", "~/Views/Shared/{0}.aspx", "~/Views/Shared/{0}.ascx" };
        base.PartialViewLocationFormats = base.ViewLocationFormats;
    }
    

    So if you didn’t like the convention of looking in the controller directory, and then shared – you could easily extend WebFormViewEngine (or use an entirely different view engine) and plop it in your global.asax:

    ViewEngines.Engines.Add(new MyViewEngine());
    

    One of the amazing things about the MVC framework is how flexible it really is. You can replace almost any part of it with your own logic – and all the code is available to see what they’ve done.

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

Sidebar

Ask A Question

Stats

  • Questions 287k
  • Answers 287k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In order to create RDL (server-based) reports in Visual Studio… May 13, 2026 at 5:06 pm
  • Editorial Team
    Editorial Team added an answer Enter -Dmaven.repo.local=%system.agent.work.dir%/.m2 for the setting Runner: Maven2 / JVM command… May 13, 2026 at 5:06 pm
  • Editorial Team
    Editorial Team added an answer Pullmonkey (http://www.pullmonkey.com/) over at the Rails Forum figured it out.… May 13, 2026 at 5:06 pm

Related Questions

I have a virtual shopping cart using sessions (sessions stored in the DB). I
I'm trying to understand the difference between using a UINavigationController inside a Nib (via
I have a simple controller which returns images: public class ImageController : Controller {
I've put all of my user-authentication code in one place, namely lib/auth.rb. It looks
I would like to know if it is acceptable/preferred to use self::method() and parent::method()

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.