Skip to content

Instantly share code, notes, and snippets.

View OzSimon's full-sized avatar

Simon Oz OzSimon

  • Sydney NSW Australia
  • 16:07 (UTC +10:00)
View GitHub Profile
@OzSimon
OzSimon / Startup.cs
Last active February 6, 2019 07:03
Asp.Net Core Startup Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
}
else {
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseResponseCaching();
@OzSimon
OzSimon / Startup.cs
Created February 6, 2019 06:52
Asp.Net Core Configure Services
public void ConfigureServices(IServiceCollection services) {
services.Configure<GzipCompressionProviderOptions>(x => x.Level = System.IO.Compression.CompressionLevel.Optimal);
services.Configure<RouteOptions>(x => { x.LowercaseUrls = true; x.AppendTrailingSlash = false; });
services.AddMemoryCache();
services.AddResponseCaching();
services.AddResponseCompression(x => { x.EnableForHttps = true; });
services.AddSingleton<IConfiguration>(Configuration);