I want to call web api controller from view by passing different parammeters.
Here is the code of the controller.
public samplecontroller:webapicontroller
{
}
If i call the controller with the following URL http://localhost/api/samplecontroller/1/2/3
1,2,3 are the parameters .I want to know how to write a method inside the controller to accept these parameters and for further processing.
If you want to automatically map URL path segments to parameters in your action you can use routing to define how that mapping happens. There’s a tutorial available here: http://www.asp.net/web-api/overview/web-api-routing-and-actions/routing-in-aspnet-web-api
In your case you could have a route like so:
Then you could have this action method: