Startup.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Microsoft.AspNetCore.Builder;
  6. using Microsoft.AspNetCore.Hosting;
  7. using Microsoft.AspNetCore.Http;
  8. using Microsoft.AspNetCore.HttpsPolicy;
  9. using Microsoft.AspNetCore.Mvc;
  10. using Microsoft.Extensions.Configuration;
  11. using Microsoft.Extensions.DependencyInjection;
  12. namespace CSCoreRedis
  13. {
  14. public class Startup
  15. {
  16. public Startup(IConfiguration configuration)
  17. {
  18. Configuration = configuration;
  19. }
  20. public IConfiguration Configuration { get; }
  21. // This method gets called by the runtime. Use this method to add services to the container.
  22. public void ConfigureServices(IServiceCollection services)
  23. {
  24. services.Configure<CookiePolicyOptions>(options =>
  25. {
  26. // This lambda determines whether user consent for non-essential cookies is needed for a given request.
  27. options.CheckConsentNeeded = context => true;
  28. options.MinimumSameSitePolicy = SameSiteMode.None;
  29. });
  30. services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  31. }
  32. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  33. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  34. {
  35. if (env.IsDevelopment())
  36. {
  37. app.UseDeveloperExceptionPage();
  38. }
  39. else
  40. {
  41. app.UseExceptionHandler("/Error");
  42. app.UseHsts();
  43. }
  44. app.UseHttpsRedirection();
  45. app.UseStaticFiles();
  46. app.UseCookiePolicy();
  47. app.UseMvc();
  48. }
  49. }
  50. }