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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:28:04+00:00 2026-06-10T12:28:04+00:00

Can I pass more than one variables to an [HttpGet] ApiController action? For example:

  • 0

Can I pass more than one variables to an [HttpGet] ApiController action? For example:

[HttpGet]
public IPagedList<Something> GetAll(int? page, string sortOrder="")
{
...
}

I tested using

curl http://localhost:[port]/api/[controller]/GetAll?page=3&sortOrder=Name

But the action was never called. The returning message is: No HTTP resource was found that matches the request URI. What went wrong?

—Update—

If I check the querystring in HttpActionContext.Request.RequestUri.Query, the AbsoluteUri truncated at the ampersand and gives me only page=3.

—End of Update

I also tried one variable:

[HttpGet]
public IPagedList<Something> GetAll(int? page)
{
...
}

The break point inside can be reached without problem in the test

curl http://localhost:%5Bport%5D/api/%5Bcontroller%5D/GetAll?page=3

I also created a view model:

public class ListRequestModel
{
    public string SortOrder { get; set; }
    public string CurrentFilter { get; set; }
    public string SearchString { get; set; }
    public int PageNumber { get; set; }
}

Action is like:

[HttpGet]
public IPagedList<Something> GetAll(ListRequestModel model)
{
...
}

Then test

curl http://localhost:%5Bport%5D/api/%5Bcontroller%5D/GetAll?PageNumber=3&SortOrder=Name

This time, the break point inside can be reached, which is a great thing. But the model is null, not populated with the data in the query string.

So, what is the correct way to pass multiple variables into an action method? Please help. Thank you.

———-Update———–

As requested, pasted below is the Routing Table in the RouteConfig.cs file:

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

In Global.asax.cs, AreaRegistration.RegisterAllAreas(); goes before RouteConfig.RegisterRoutes(RouteTable.Routes); But no Area routes start with api. All my other tests on this ApiController can get into the action without problem.

  • 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-10T12:28:06+00:00Added an answer on June 10, 2026 at 12:28 pm

    Your routing and setup is fine. And of course that you can pass multiple arguments to a controller.

    You just need to improve your Linux foo because & has a special meaning in Linux shells…

    From Wikipedia:

    • Some Unix shells use the ampersand as a metacharacter:
    • Some Unix shells, like the POSIX standard sh shell, use the ampersand to execute a process in the background and to duplicate file
      descriptors.
    • In Bash, the ampersand can separate words, control the command history, duplicate file descriptors, perform logical operations,
      control jobs, and participate in Regular expressions.

    So you need escape the ampersand & with a backlash \ in your your command

    curl http://localhost:[port]/api/[controller]/GetAll?page=3\&sortOrder=Name
    

    Or use quotation marks "" around the url:

    curl "http://localhost:[port]/api/[controller]/GetAll?page=3&sortOrder=Name"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I pass more than one parameter from jQuery to an ASHX file.
In C, how can i pass more than one argument to a thread? Normally,
I want to pass multiple (more than one) query string in an anchor tag.
How can I use SetProcessAffinityMask to select more than one logical processor? In Windows
I tried to pass more than one parameter through URL using python, i wrote
Hallo, how can I pass more parameters to usort? I have different functions, which
in MongoDb I can pass a predicate to an queryable instance for example DataBase.GetCollection<BsonDocument>(entity)
Is there any way that I can pass arguments in selector? example: I have
Possible Duplicate: Multiple arguments to function called by pthread_create()? How to pass more than
How can I pass multiple variables between PHP files using jquery with json? Ex:

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.