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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:25:08+00:00 2026-06-07T18:25:08+00:00

In my initial stab at creating a MVC4 Web API. I’ve noticed a few

  • 0

In my initial stab at creating a MVC4 Web API. I’ve noticed a few things about the way routes are handled that seems a little off:

  • Controllers no longer ever have more than 4 actions?
  • A resource that only supports one HTTP verb still gets it’s very own controller?
  • The route hierarchy tends to be very flat, OR
  • An extremely large number of routes must be specified/maintained compared to MVC apps for humans.

I’ve created fairly large sites that use only two or three routes, but I’m just starting on my API and I’m up to almost a dozen. I guess APIs by their nature lend themselves to deeper URLs than websites, but this seems a little excessive.

I feel like I’m missing a namespace somewhere or a routing convention. I attribute nearly all of this to the fact that action names are no longer part of the route, just the HTTP method. Is there a way to support routes by anything other than parameter matching, controller name, and HTTP method?

  • 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-06-07T18:25:10+00:00Added an answer on June 7, 2026 at 6:25 pm

    You can modify the routing in Global.asax. The default is set to:

               routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
    

    But you could change it for example to use the action name:

    routes.MapHttpRoute(
    name: "ActionApi",
    routeTemplate: "api/{controller}/{action}/{id}",
    defaults: new { id = RouteParameter.Optional }
    

    For more information on custom routing in MVC WEb API look at this article.

    Update based on comments

    Above was the answer to the question, “can I change the routing?” The short answer is yes, but as was pointed out in another answer you may not want to and maintain a good REST API. MVC Web API with it default routing maintains the basic REST concept that you are working on resources, with the controller representing the resource. In your other question you give the example:

    DELETE /account/1234/note/321 <- delete note 321 on account 1234
    

    Where you want to delete a note on account 1234. In this case the resource you are working on is a note. A better representation for this would be to use query string so your API for this example would look like this:

    DELETE /note/321?account=1234 <- delete note 321 on account 1234
    

    This way you do not need to mess with the routing and it is clear that the resource being acted upon is a note with filters being used. But I would also question whether adding this explicit filter (i.e. where clause) is necessary if the id for note is unique for the whole application and not just for a specific account.

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

Sidebar

Related Questions

I've noticed that initial comment in JavaScript or CSS files is sometimes started with
Initial Googling indicates that there's no built-in way to do regular expressions in an
Initial Question Yesterday i read about ECMAScript 5 Object.create() And I wanted to start
Initial tests indicate that GDI+ (writing in VB.NET) is not fast enough for my
My initial task was to find a segmenter for Windows that will split a
I am in initial stage of MDM Server implementation, I know that when ever
Initial deployment of the site works fine. After about 2-3 hours, the controllers suddenly
The initial situation is that I map my domain model into a presentation model.
INITIAL QUESTION: I have an app that uses ExecutorService to run 4 fixedThreadPool. When
Editing because the initial code was confusing. I would assume these two things to

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.