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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:02:28+00:00 2026-06-04T14:02:28+00:00

I have 2 API routes for my API atm, but I want to add

  • 0

I have 2 API routes for my API atm, but I want to add more, and the way I am doing it it seems to overwrite each other, so in the code I pasted, only the CreateUser route works.

public static void RegisterRoutes(RouteCollection routes)
{
    routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
    routes.MapHttpRoute(
        name: "CreateUser",
        routeTemplate: "api/{controller}/{cUser}",
        defaults: new
        {
            controller = "User",
            action = "CreateUser",
            cUser = RouteParameter.Optional
        });
    routes.MapHttpRoute(
        name: "AllGames",
        routeTemplate: "api/{controller}/{playerId}",
        defaults: new
        {
            controller = "Game",
            action = "GetAllGames",
            playerId = RouteParameter.Optional
        });
    routes.MapRoute(
        name: "Default",
        url: "{controller}/{action}/{id}",
        defaults: new
        {
            controller = "Home",
            action = "Index",
            id = UrlParameter.Optional
        });
}
  • 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-04T14:02:28+00:00Added an answer on June 4, 2026 at 2:02 pm

    I believe the pattern api/{controller}/{cUser} in “CreateUser” route is matching with rest of the controller actions because of its more generic pattern. Use specific controller name in the routes as “User” (api/User/{cUser}) and “Game” (api/Game/{playerId}). The more specific routes should be at the top and more generic at the bottom.

    routes.MapHttpRoute(
        name: "CreateUser",
        routeTemplate: "api/User/{cUser}",
        defaults: new
        {
            controller = "User",
            action = "CreateUser",
            cUser = RouteParameter.Optional
        }
    );
    
    routes.MapHttpRoute(
        name: "AllGames",
        routeTemplate: "api/Game/{playerId}",
        defaults: new
        {
            controller = "Game",
            action = "GetAllGames",
            playerId = RouteParameter.Optional
        }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In express, I have defined some routes app.post(/api/v1/client, Client.create); app.get(/api/v1/client, Client.get); ... I have
I have an api which takes uni code data as c character array and
I want to have my API controller use SSL, so I added another listen
We have a RESTful API that we are doing in MVC3. We would like
I already have this in my routes file: namespace :api do root :to =>
I have used the google map API to plot a way point on google
I have a situation where I want to make a request to third-party API(url
In my API, I'd like to have routes like GET /api/v1/widgets/1,2,3 and GET /api/v1/widgets/best-widget,major-widget,bob-the-widget
I have routes like this namespace :api, defaults: {format: 'json'} do namespace :v1 do
I see many Java packages have api, impl and bundle jars (name-api.jar, name-impl.jar, name-bundle.jar).

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.