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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:12:04+00:00 2026-06-16T00:12:04+00:00

I am attempting to write an API. The signatures look like this: public class

  • 0

I am attempting to write an API. The signatures look like this:

public class CardsController : ApiController
{
    [HttpGet]
    public ClientData NewGame(){...}
    [HttpGet]
    public ClientData Deal(int sessionId){...}
    [HttpGet]
    public ClientData Stand(int sessionId){...}
}

With everything else at default I was getting an error saying my class couldn’t differentiate between Deal and Stand. After a bit of research I found it was a routing issue. So I decided to update my routing.

My global.asax.cs now looks like this:

public class MvcApplication : HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();

        WebApiConfig.Register(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        AuthConfig.RegisterAuth();
        RegisterRoutes(RouteTable.Routes);
    }

    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.MapHttpRoute("api", "api/{controller}/{action}/{value}", new { value = RouteParameter.Optional});
    }
}

Going to http://localhost:54924/api/Cards/Stand/19 gives an error that says no HttpResource was found, and going to http://localhost:54924/api/Cards/Stand triggers the NewGame() action. How can I get Stand and Deal to work on the same controller?

  • 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-16T00:12:04+00:00Added an answer on June 16, 2026 at 12:12 am

    Add the routes:

    routes.MapHttpRoute("DealApi", 
                        "api/{controller}/deal/{sessionId}",
                        new { action="Deal", sessionId = RouteParameter.Optional });
    
    
    routes.MapHttpRoute("StandApi", 
                        "api/{controller}/stand/{sessionId}",
                        new { action="Stand", sessionId = RouteParameter.Optional });
    

    Now, in your Controller class:

    [HttpGet]
    [ActionName("Deal")]
    public ClientData Deal(int sessionId){...}
    
    [HttpGet]
    [ActionName("Stand")]
    public ClientData Stand(int sessionId){...}
    

    Now, whenever you pull up the url http://www.yourhost.com/api/deal/12345, the Deal function will be called. Same thing with Stand.

    Keep in mind that whatever you set in your routes tables are only for recognizing whether a url is valid. By having the action specified in the third parameter, you’re telling Web Api to find a function whose ActionName attribute is set to what you specify.

    Another thing – put those two routes BEFORE any of your default api routes.

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

Sidebar

Related Questions

Currently I'm attempting to write my own wxObject, and I would like for the
I am attempting to write this html in haml so as to add an
I'm attempting to write a C# managed class to wrap SHGetKnownFolderPath, so far it
I attempting to write a simple JQuery search. This is what I have so
I am attempting to write some simple code in F#, and i get this
When attempting to write/read cookies that have brackets in the name, it seems like
I am attempting to write an android game involving a class which extends SurfaceView
I am curretnly attempting to write a script in python that allows me to
I am attempting to write an Android app which will allow me to read
I am attempting to write a method that has an optional EventHandler Paramater. it

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.