Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Last active Mar 23, 2016
Embed
What would you like to do?
ASP.NET Core Tips & Tricks
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory logger)
{
logger.AddConsole(this.Configuration.GetSection("Logging"));
logger.AddDebug();
try
{
app.UseIISPlatformHandler();
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
...
}
catch (Exception ex)
{
app.Run(
async context =>
{
log.LogError($"{ex.Message}");
context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
context.Response.ContentType = "text/plain";
await context.Response.WriteAsync(ex.Message).ConfigureAwait(false);
await context.Response.WriteAsync(ex.StackTrace).ConfigureAwait(false);
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment