public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider) { app.UseQuartz(); app.UseCors("CorsPolicy"); app.UseExceptionHandler(eApp => { eApp.Run(async context => { context.Response.StatusCode = StatusCodes.Status500InternalServerError; context.Response.ContentType = "application/json"; var errorCtx = context.Features.Get <IExceptionHandlerFeature>(); if (errorCtx != null) { var ex = errorCtx.Error; WebHelper.LogWebError("Exception", Constants.General.ApiName, ex, context); var errorId = Activity.Current?.Id ?? context.TraceIdentifier; var jsonResponse = JsonConvert.SerializeObject(new CustomErrorResponse { ErrorId = errorId, Message = "An error occurred in the api. If you need assistance please contact our support with the given errorId." }); await context.Response.WriteAsync(jsonResponse, Encoding.UTF8); } }); }); app.UseSignalR(routes => { routes.MapHub <StockHub>("/coolmessages"); }); AutomapperConfiguration.ConfigureProfiles(); app.UseSwaggerDocumentation() .UseStatusCodePages() .UseAuthentication() .UseMvc(); }