A
A
Andrey2018-10-24 17:29:11
ASP.NET
Andrey, 2018-10-24 17:29:11

Web Api how to make multiple parameters in Get request? And do they do it?

Good day everyone!
Tell me, please, to a beginner how in web api and is it possible to pass several parameters in a request?
I'm doing a tutorial on Metathite. There is a test user base:

public class User
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public int Age { get; set; }
    }

I fill it
db.Users.Add(new User { Name = "Tom", Age = 26 });
db.Users.Add(new User { Name = "Alice", Age = 32 });
db.Users.Add(new User { Name = "Bob", Age = 26 });
db.Users.Add(new User { Name = "Ken", Age = 32 });

How to display all users whose age is 32 and whose name starts with "A" using a Get query?
Or is it done differently? Because it causes a compile-time error. What to read? Thanks in advance! [HttpGet("{age/name}")]

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question