0

I am new with ASP.NET Web API and have been researching this for some time now. Admittedly, I have decision paralysis. I would like to create a REST-like web Api for a system.

It seems as if I need to create an ApiController for basically every table in the database that I want to exposed via the API. If you only have GET, PUT, POST, DELETE, etc. for a controller, how can a controller handle GET requests for multiple entities, let's say, an Account table and a Lead table??

It seems an IHttpHandler would be way more flexible to handle requests for multiple types of resources. Please help, banging head on desk.

1 Answers1

0

There should be seprate ApiController for Account and lead table, now if you are asking to handle two Get action in Account controller you can differentiate No./Types of parameters.

For eg.

public string GetDetailsById(int id);
public string GetDetailsByName(string name);

To call above method

/api/account/{id}
/api/account/?name={name}

Rashmin Javiya
  • 5,173
  • 3
  • 27
  • 49