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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:03:54+00:00 2026-05-14T23:03:54+00:00

So my application is growing and I’d like to split out my View-based controllers

  • 0

So my application is growing and I’d like to split out my View-based controllers from my JSON-based controllers. Basically, I have a bunch of controllers that all they do is return JSON results for AJAX calls.

What I would like to do would be to set up the routes (and the folder structure under my Controllers folder, for that matter) such that my JSON controllers live under /RPC/ and my regular controllers live under / — i.e. my JavaScript would call /RPC/SomeController/SomeAction and my regular pages would live under /SomeOtherController/SomeOtherAction.

So what I did was I set up my Controllers folder as such:

  • Controllers (folder)
    • RPC (folder)
      • JsonController1
      • JsonController2
    • ViewController1
    • ViewContoller2
    • ViewController3

I wasn’t able to just go to /RPC/JsonController1/Index and have that work so then I set up my routes as follows:

protected void Application_Start()
{
 AreaRegistration.RegisterAllAreas();

 RegisterRoutes(RouteTable.Routes);

 // Register new annotations.
 DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(UniqueUsernameAttribute), typeof(UniqueUsernameValidator));
}

public static void RegisterRoutes(RouteCollection routes)
{
 // Add the combres routes, too
 routes.AddCombresRoute("Combres");
 routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

 routes.MapRoute("RPC", 
  "RPC/{controller}/{action}/{id}", 
  new { controller = "None", action = "Index", id = UrlParameter.Optional },
  new[] { "Backplane.Web.Controllers.RPC" }
 );

 routes.MapRoute(
  "Default", // Route name
  "{controller}/{action}/{id}", // URL with parameters
  new { controller = "Home", action = "Index", id = UrlParameter.Optional }, // Parameter defaults
  new[] { "Backplane.Web.Controllers" }
 );
}

This works just great! My controllers are accessible under both /RPC/ and /! Unforunately I can validly access /RPC/ViewController1/and I can also validly access /JsonController1/.

It seems that I have a fundamental misunderstanding about routing and how it’s related to the physical path on the file system. Will I need a custom route scheme here? I’d like to keep all of this in the same project as I’d like to keep all the controllers in the same DLL.

  • 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-14T23:03:55+00:00Added an answer on May 14, 2026 at 11:03 pm

    The routing is not related to the physical path on the file system (either on the build machine or on the server). The routing is performed at run-time, at which point there are no artifacts that would suggest the MVC routing handler where on the file system particular class was located. As such, the routing is dependent only on the order of the routes in the routing table (which depends on the order of them in the Global.asax.cs) and how the URL path parts map onto the routes and the controller classes names and actions.

    The easiest solution to make your scenario work is to remove the Default rule and list explicit rules for any controller under the root.

    Another approach would be to move all your RPC controllers into a separate area (Areas/RPC/Controllers) in your solution. The way the areas work is that any /rpc/* path is mapped to the RPC area. There are certain caveats with that approach as well, but in general it should work, as the area routes are registered after the main routes and the MVC routing does an attempt to avoid using controllers that are part of an area with URLs that don’t map to that area.

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

Sidebar

Ask A Question

Stats

  • Questions 405k
  • Answers 405k
  • 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 Which answer are you using code from? Assuming it was… May 15, 2026 at 5:55 am
  • Editorial Team
    Editorial Team added an answer when i use [temp retain] does the counter of the… May 15, 2026 at 5:55 am
  • Editorial Team
    Editorial Team added an answer For table contents to be visible its tags must be… May 15, 2026 at 5:55 am

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.