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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:32:55+00:00 2026-06-17T23:32:55+00:00

I am having difficulty with a nested Web API routing set-up. Given a routing

  • 0

I am having difficulty with a nested Web API routing set-up.

Given a routing config of:

config.Routes.MapHttpRoute(
    name: "UsersGroups",
    routeTemplate: "api/users/{userID}/groups/{groupID}",
    defaults: new { controller = "UsersGroups", groupID = UrlParameter.Optional }
);

and controller actions like thus:

public AuthGroup Get(long userID, int groupID)
{
     //Get specific group here
}

public IEnumerable<AuthGroup> Get(long userID)
{
    //get all groups for user here
}

Calling this route /api/users/1528/groups gives this error:

The parameters dictionary contains a null entry for parameter groupID of non-nullable type System.Int32 for method AuthGroup Get(Int64, Int32) in UsersGroupsController. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.

I was expecting it to grab the action with the single long parameter, but obviously for some reason it’s ignoring this and going straight for the one with most arguments.

Based on what’s available at MS on how Web API interprets routes: http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-and-action-selection I think what I have should be correct, but obviously it is not working as it seems like it should.

  • 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-17T23:32:56+00:00Added an answer on June 17, 2026 at 11:32 pm

    You should use RouteParameter.Optional (from Web API), not UrlParameter.Optional (from ASP.NET MVC).

    Everything will behave as you want then.

    More info:

    • UrlParameter.Optional – http://msdn.microsoft.com/en-us/library/system.web.mvc.urlparameter.optional(v=vs.108).aspx

    • RouteParameter.Optional – http://msdn.microsoft.com/en-us/library/system.web.http.routeparameter.optional(v=vs.108).aspx

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

Sidebar

Related Questions

I'm having some difficulty creating nested objects between a one-to-many relationship. My models are
I'm having difficulty nested quotes within a bash script argv=su -c '$RVM_PATH wrapper $config_rvm
Having difficulty finding relevant search results... Given this model: public abstract class A {
Im having difficulty in understanding how the pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)rowinComponent:(NSInteger)component works Ive set up
I'm having difficulty targeting a nested span injected by JQM above a select group.
I'm having some difficulty to solve this kind of problem: I Have some nested
I'm having some difficulty with an Update statement. UPDATE DownPeriod SET DownPeriod.EquipmentID = ?
I'm having some difficulty understanding the documentation for declarative authorization and nested if_attributes. Models:
Having difficulty indexing an attachment type in elasticsearch via the Tire gem. Not able
Im having difficulty trying to design a database structure for the following scenario: My

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.