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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:40:44+00:00 2026-06-01T03:40:44+00:00

Let say I have two methods in MVC 4 Web API controller: public IQueryable<A>

  • 0

Let say I have two methods in MVC 4 Web API controller:

public IQueryable<A> Get() {}

And

public A Get(int id) {}

And the following route:

routes.MapHttpRoute(
    name: "Default", 
    routeTemplate: "{controller}/{id}",
    defaults: new { id = RouteParameter.Optional }
);

This works as expected. Adding a one more parameter, e.g.:

public IQueryable<A> Get(int p) {}

public A Get(int id, int p) {}

leads to the situation when MVC returns 404 for the following request:

GET /controller?p=100

Or

GET /controller/1?p=100

with message “No action was found on the controller ‘controller’ that matches the request”

I expect that URL parameters should be wired by MVC without issues, but it is not true. Is this a bug or my misunderstanding of how MVC maps request to 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-01T03:40:46+00:00Added an answer on June 1, 2026 at 3:40 am

    If you think about what you’re attempting to do and the routes you’re trying, you’ll realize that the second parameter “p” in your case, needs to be marked as an optional parameter as well.

    that is your route should be defined like so:

    routes.MapHttpRoute(
    name: "Default", 
    routeTemplate: "{controller}/{id}/{p}",
    defaults: new { id = RouteParameter.Optional, p = RouteParameter.Optional });
    

    Once you do this, the URL

    /controller?p=100
    will map to your

    public IQueryable<A> Get(int p) {}
    

    method and a URL like so:

     /controller/1?p=100
    

    will map to your

    public A Get(int id, int p) {}
    

    method, as you expect.

    So to answer your questions….no this is not a bug but as designed/expected.

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

Sidebar

Related Questions

Let's say I have two classes like the following: Class A { public: ..
Let's say I have two arrays: int ArrayA[] = {5, 17, 150, 230, 285};
Let say I have a method (example taken from another post): public IQueryable<CityBlock> GetCityBlocks(){
Let's say you have a class class C { int * i; public: C(int
Let's say I have two classes that look like this: public class ByteFilter {
Let's say that I have two methods defined with the same name and return,
Let's say you have two collections of integers: IEnumerable<int> col1=new List<int> {2,3,3,5,7,11,11,11,13}; IEnumerable<int> col2=new
Let's say I have a structure named vertex with a method that adds two
In tab container let say I have two tabs [Tab1 & Tab2] Tab1 has
Let say I have are two WPF forms: Form1 and Form2 . Form1 contains

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.