Startup.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 HaBookCms.Contest
  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_2);
  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("/Home/Error");
  42. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  43. app.UseHsts();
  44. }
  45. app.UseHttpsRedirection();
  46. app.UseStaticFiles();
  47. app.UseCookiePolicy();
  48. app.UseMvc(routes =>
  49. {
  50. routes.MapRoute(
  51. name: "default",
  52. template: "{controller=Home}/{action=Index}/{id?}");
  53. });
  54. }
  55. }
  56. }