I'm setting up a new server for web api, but when I try to make a post request from two individual client, server only responds to the first one. From second one, I always get 500 Internal Server Error.
I tried to make all methods in the server as async but same error has occured.
I call the web service as below:
using(var client = new HttpClient())
{
client.BaseAddress = new Uri("http://serverdomain/ApiName/")
var response = client.PostAsync("controller/method",
keyvaluepairContent);
result = response.Result.Content.ReadAsAsync<List<string>>().Result;
}
And the relevant service code is below:
[Route("controller/method")]
[AcceptVerbs("POST")]
public List<string> Foo([FromBody] someparams)
{
//some logic
}
I wrote the config file as :
config.Routes.MapHttpRoute(
name : "DefaultApi",
routeTemplate : "{controller}/{action}/{id}",
defaults : new { id = RouteParameter.Optinal }
);
For one client at the same time, the server is working very well. I get what I need. However, when two clients make requests even for different methods, the delayed one always gets 500 Internal Error. Debugger says that this code below cannot parse the result, that is beacuse the response is not a string list but the error above.
result = response.Result.Content.ReadAsAsync<List<string>>().Result;
I think my code is fine, but I need to configure my web api. I did searched about it but no result.