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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:01:34+00:00 2026-06-10T10:01:34+00:00

I have a web project with two models – IndicatorModel and GranteeModel . I

  • 0

I have a web project with two models – IndicatorModel and GranteeModel. I also have corresponding ApiControllers for each – IndicatorsController, and GranteesController. I’m planning on using this setup for a data API alongside my actual web project, so I’ve created a new Area in my project named simply “Api”. In my ApiAreaRegistration class, I’m registering routes for these controllers like this:

context.Routes.MapHttpRoute(
  name: "ApiDefault",
  routeTemplate: "api/{controller}/{id}",
  defaults: new { id = RouteParameter.Optional }
);

Basically, a request to http://myapp/api/indicators/123 should go to the Indicators controller, and it should specifically be handled by an action method that accepts an integer parameter. My controller class is setup as follows, and it works perfectly:

public class IndicatorsController : ApiController
{
    // get: /api/indicators/{id}
    public IndicatorModel Get(int id)
    {
        Indicator indicator = ...// find indicator by id
        if (indicator == null)
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
        return new IndicatorModel(indicator);
    }
}

My GranteesController class is setup identically:

public class GranteesController : ApiController
{
    // get: /api/grantees/{id}
    public GranteeModel Get(int granteeId)
    {
        Grantee grantee = ... // find grantee by Id
        if (grantee == null)
        {
            throw new HttpResponseException(HttpStatusCode.NotFound);
        }
        return new GranteeModel(grantee);
    }
}

Now the problem – if I try a request to http://myapp/api/grantees/123, I get a 404 and I’m 100% positive that the 404 is not coming from my Get method. For one, I’ve tried debugging and logging within that method, and the method is never actually hit. Also, the actual output (json) to the request looks like this:

{ 
  "Message": "No HTTP resource was found that matches the request URI 'http://myapp/api/grantees/25'.",
  "MessageDetail": "No action was found on the controller 'Grantees' that matches the request."
}

Also, the output to my TraceWriter log looks like this:

;;http://myapp/api/grantees/10
DefaultHttpControllerSelector;SelectController;Route='controller:grantees,id:10'
DefaultHttpControllerSelector;SelectController;Grantees
HttpControllerDescriptor;CreateController;
DefaultHttpControllerActivator;Create;
DefaultHttpControllerActivator;Create;MyApp.Areas.Api.Controllers.GranteesController
HttpControllerDescriptor;CreateController;MyApp.Areas.Api.Controllers.GranteesController
GranteesController;ExecuteAsync;
ApiControllerActionSelector;SelectAction;
DefaultContentNegotiator;Negotiate;Type='HttpError', formatters=[JsonMediaTypeFormatterTracer...

So my request is getting routed correctly – the correct controller is selected, and the Id property is set correctly (10). However, the ApiControllerActionSelector isn’t finding a method on the controller which matches. I’ve also tried adding in the [HttpGet] attribute to my Get methods, with no success.

Does anyone have any ideas of what might be happening here? I cannot for the life of me figure out why the action selector isn’t finding the correct action.

  • 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-10T10:01:40+00:00Added an answer on June 10, 2026 at 10:01 am

    The parameter name on GranteesController’s action need to be modified from ‘granteeId’ to ‘id’:

    public GranteeModel Get(int id)

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

Sidebar

Related Questions

I have two web application projects (project A and project B) in the same
I have two projects in my solution   1- asp.net web project.   2-
I have two projects in my solution... a domain project and MVC3 web project
This is probably a basic question. I have two projects: A web application project,
I have one web application with two projects: Project Website Using CMS; namespace Web
OK I have two web projects WebProject1 & WebProject2. Both require database connectivity so
Let's say I have two maven profiles for running projects web tests: 1. first
I have web application Project having RPC call. one RPC async is working fine.
I have a web project in Asp.net MVC where in many pages, there is
I have a web project with devexpress component ASPxGridView. So I want to know

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.