public EtymologyController(EtymologyContext context, ILogger <EtymologyController> logger, IMemoryCache etymologyCache, ICharacterCache characterCache) { this.context = context ?? throw new ArgumentNullException(nameof(context)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.etymologyCache = etymologyCache; this.characterCache = characterCache; }
public void Configure(IApplicationBuilder application, ILoggerFactory loggerFactory, IAntiforgery antiforgery, Settings settings, EtymologyContext etymologyContext, ICharacterCache characterCache) // HTTP pipeline. { if (this.environment.IsProduction()) { application .UseExceptionHandler("/error") .UseStatusCodePagesWithReExecute("/error") .UseHsts() .UseHttpsRedirection(); } else { application.UseDeveloperExceptionPage().UseBrowserLink(); } application .UseAntiforgery(settings, antiforgery, loggerFactory.CreateLogger(nameof(RequestValidation))) .UseDefaultFiles() .UseStaticFiles(new StaticFileOptions { OnPrepareResponse = staticFileResponseContext => staticFileResponseContext.Context.Response.Headers[HeaderNames.CacheControl] = $"public,max-age={Cache.ClientCacheMaxAge}" }) .UseResponseCaching() .UseMvc(routes => routes.MapRoute(name: "default", template: "{controller}/{action}")); characterCache.Initialize(etymologyContext).Wait(); // Async Configure method is not supported by ASP.NET. // https://github.com/aspnet/Hosting/issues/373 // Add support for GB18030. Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); }