I am using HttpClient to invoke this web API
using (var client = new HttpClient(new HttpClientHandler() { Credentials = _credentials }))
{
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return await client.PostAsJsonAsync(controlActionPath, entityObject);
}
Web API controller I am throwing bellow error:
throw new DuplicateNameException("User already exists.");
However web app always getting internal server error instead of DuplicateNameException
.
It would be helpful, if someone suggest what will be the best way to get the exact exception back to Web application from Web API.