We help IT Professionals succeed at work.
Get Started

How to use more than one parameter for HttpGet (MVC/WebAPI)

Last Modified: 2016-07-26
I need to change my WebApi (asp.net Core) controller to add one special GET action that accepts more than 1 parameter. Instead of the regular stuff:
        public string Get(int id)
            //var result = rep.GetAccount(id);
            return "Regular way hit";

Open in new window

I need to send in multiple parameters or a dto containing those parameters. So basically something like this:
        public string Get(AccountDTO dto)
            //var result = rep.GetAccount(dto.AccountNumber, dto.AccountName, dto.BrokerName, dto.Symbol);
            return "Hit it";

Open in new window

I can't figure out if this should be done by adding attributes to the HttpGet, or if I need a special route (and if so how to do that).

Watch Question
IT Professional
Top Expert 2015
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE