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 840357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:36:35+00:00 2026-05-15T05:36:35+00:00

We’re building a site that will have very minimal code, it’s mostly just going

  • 0

We’re building a site that will have very minimal code, it’s mostly just going to be a bunch of static pages served up. I know over time that will change and we’ll want to swap in more dynamic information, so I’ve decided to go ahead and build a web application using ASP.NET MVC2 and the Spark view engine. There will be a couple of controllers that will have to do actual work (like in the /products area), but most of it will be static.

I want my designer to be able to build and modify the site without having to ask me to write a new controller or route every time they decide to add or move a page. So if he wants to add a “http://example.com/News” page he can just create a “News” folder under Views and put an index.spark page within it. Then later if he decides he wants a /News/Community page, he can drop a community.spark file within that folder and have it work.

I’m able to have a view without a specific action by making my controllers override HandleUnknownAction, but I still have to create a controller for each of these folders. It seems silly to have to add an empty controller and recompile every time they decide to add an area to the site.

Is there any way to make this easier, so I only have to write a controller and recompile if there’s actual logic to be done? Some sort of “master” controller that will handle any requests where there was no specific controller defined?

  • 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-15T05:36:36+00:00Added an answer on May 15, 2026 at 5:36 am

    You will have to write a route mapping for actual controller/actions and make sure the default has index as an action and the id is “catchall” and this will do it!

        public class MvcApplication : System.Web.HttpApplication {
            public static void RegisterRoutes(RouteCollection routes) {
                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    
                routes.MapRoute(
                    "Default", // Route name
                    "{controller}/{action}/{id}", // URL with parameters
                    new { controller = "Home", action = "Index", id = "catchall" } // Parameter defaults
                );
    
            }
    
            protected void Application_Start() {
                AreaRegistration.RegisterAllAreas();
    
                RegisterRoutes(RouteTable.Routes);
    
                ControllerBuilder.Current.SetControllerFactory(new CatchallControllerFactory());
    
            }
        }
    
    public class CatchallController : Controller
        {
    
            public string PageName { get; set; }
    
            //
            // GET: /Catchall/
    
            public ActionResult Index()
            {
                return View(PageName);
            }
    
        }
    
    public class CatchallControllerFactory : IControllerFactory {
            #region IControllerFactory Members
    
            public IController CreateController(System.Web.Routing.RequestContext requestContext, string controllerName) {
    
                if (requestContext.RouteData.Values["controller"].ToString() == "catchall") {
                    DefaultControllerFactory factory = new DefaultControllerFactory();
                    return factory.CreateController(requestContext, controllerName);
                }
                else {
                    CatchallController controller = new CatchallController();
                    controller.PageName = requestContext.RouteData.Values["action"].ToString();
                    return controller;
                }
    
            }
    
            public void ReleaseController(IController controller) {
                if (controller is IDisposable)
                    ((IDisposable)controller).Dispose();
            }
    
            #endregion
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

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.