Startup.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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.Http.Features;
  9. using Microsoft.AspNetCore.HttpsPolicy;
  10. using Microsoft.AspNetCore.Mvc;
  11. using Microsoft.Extensions.Caching.Memory;
  12. using Microsoft.Extensions.Configuration;
  13. using Microsoft.Extensions.DependencyInjection;
  14. namespace Cksoft.WebMainFrame
  15. {
  16. public class Startup
  17. {
  18. public Startup(IConfiguration configuration)
  19. {
  20. Configuration = configuration;
  21. }
  22. public IConfiguration Configuration { get; }
  23. // This method gets called by the runtime. Use this method to add services to the container.
  24. public void ConfigureServices(IServiceCollection services)
  25. {
  26. services.Configure<FormOptions>(options =>
  27. {
  28. options.ValueCountLimit = 5000; // 5000 items max
  29. options.ValueLengthLimit = 1024 * 1024 * 100; // 100MB max len form data
  30. });
  31. services.Configure<CookiePolicyOptions>(options =>
  32. {
  33. // This lambda determines whether user consent for non-essential cookies is needed for a given request.
  34. //options.CheckConsentNeeded = context => true;
  35. options.CheckConsentNeeded = context => false;//session取不到值时,将此值修改为false
  36. options.MinimumSameSitePolicy = SameSiteMode.None;
  37. });
  38. services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  39. }
  40. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  41. public void Configure(IApplicationBuilder app, IHostingEnvironment env)
  42. {
  43. if (env.IsDevelopment())
  44. {
  45. app.UseDeveloperExceptionPage();
  46. }
  47. else
  48. {
  49. app.UseExceptionHandler("/Home/Error");
  50. app.UseHsts();
  51. }
  52. app.UseHttpsRedirection();
  53. app.UseStaticFiles();
  54. app.UseCookiePolicy();
  55. app.UseMvc(routes =>
  56. {
  57. routes.MapRoute(
  58. name: "default",
  59. template: "{controller=Home}/{action=AdminWindos}/{id?}");
  60. });
  61. }
  62. }
  63. }