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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:43:32+00:00 2026-06-09T02:43:32+00:00

I have webapi controller with 2 action methods like so: public List<AlertModel> Get() {

  • 0

I have webapi controller with 2 action methods like so:

public List<AlertModel> Get()
{
    return _alertService.GetAllForUser(_loginService.GetUserID());
}

public AlertModel Get(int id)
{
    return _alertService.GetByID(id);
}

However, when I make a request to api/alerts I get the following error:

The parameters dictionary contains a null entry for parameter ‘id’ of
non-nullable type ‘System.Int32’ for method
‘ekmSMS.Common.Models.AlertModel Get(Int32)’ in
‘ekmSMS.Web.Api.AlertsController’. An optional parameter must be a
reference type, a nullable type, or be declared as an optional
parameter.

I have the following route set up in global.asax:

routes.MapHttpRoute("Api", "api/{controller}/{id}", new { id = UrlParameter.Optional });

Should this type of overloading work? And if it should what am I doing wrong?

EDIT

Although this question is about WebAPI, the controllers are part of a MVC3 project, these are the other MapRoutes:

routes.MapRoute("Templates", "templates/{folder}/{name}", new { controller = "templates", action = "index", folder = "", name = "" });    
routes.MapRoute("Default", "{controller}/{action}/{id}", new { controller = "app", 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-09T02:43:34+00:00Added an answer on June 9, 2026 at 2:43 am

    The problem is that you used UrlParameter.Optional (which is an ASP.NET MVC specific type) instead of RouteParameter.Optional. Change your route as below and then it should work:

    GlobalConfiguration.Configuration.Routes.MapHttpRoute(
        "Api",
        "api/{controller}/{id}",
        new { id = RouteParameter.Optional }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>
I have a controller action in web api that return string token as below.Howver,
I have a Web API controller action which has a parameter of type CommandMessage.
Using the ASP.NET Web-Api, I have the following POST setup in my controller. When
I have MVC webApi application which works with Unity . I have to resolve
I have a desktop webapi server that I want to expose to clients through
I have a Asp.net WebAPI service that is hosted on AppHarbor which throws 404
I have a layered web application that I built with ASP.NET MVC 4, WebAPI
I've created a method using the new WebAPI features in MVC4 and have it
I have created a class which extends HttpServlet in a package called controller I

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.