//Startup.cs After this
app.UseGoogleTrace();
app.UseExceptionHandler(
options =>
{
options.Run(
async context =>
{
context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); //Allow Origin
context.Response.Headers.Add("Access-Control-Allow-Origin", "*"); //Allow Origin
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
context.Response.ContentType = "application/json";
var ex =
context.Features.Get<IExceptionHandlerFeature>();
if (ex != null)
{
var err = JsonConvert.SerializeObject(ex.Error);
await
context.Response.WriteAsync(err).ConfigureAwait(false);
}
});
}
);
//Before this
app.UseMvc();
----------------
try
{
return Ok(result);
}
catch (Exception ex)
{
throw ex;
}