HomeASP.NETPassing Array of Integers to ASP.NET Web API REST Service

Passing Array of Integers to ASP.NET Web API REST Service

You can pass an array of integer to an ASP.NET Web Web API REST service by setting the [FromUri] attribute for the parameter of the action method.

How to pass an array of integer to ASP.NET Web API REST Service?

Assume that you want to access the Employees with the id’s 1,2,3 and you would like to pass them in the parameter of the URL and retreive this as the array of integers in the action method. Here’s how your action method will look like.

public IHttpActionResult GetEmployees([FromUri] int[] employeeIds)
{
    return Ok();
}

Leave a Reply

You May Also Like

You can read connection string from web.config file in ASP.NET by using the ConfigurationManager class in case you want to...
When you deploy your ASP.NET Web Application on Windows Server running IIS , there are times that you might receive...
This post will explain how to resolve the error “Handler “aspNetCore” has a bad module “AspNetCoreModuleV2” in its module list”...