Startup.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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.HttpsPolicy;
  8. using Microsoft.AspNetCore.Mvc;
  9. using Microsoft.Extensions.Configuration;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.Hosting;
  12. using Microsoft.Extensions.Logging;
  13. using log4net;
  14. using Microsoft.Extensions.Caching.Memory;
  15. using Newtonsoft.Json.Serialization;
  16. using Microsoft.Net.Http.Headers;
  17. using ApiProcess.Process;
  18. using Microsoft.AspNetCore.Server.Kestrel.Core;
  19. namespace ApiProcess
  20. {
  21. public class Startup
  22. {
  23. static string CACHE_KEY = "CacheKey";
  24. public Startup(IConfiguration configuration)
  25. {
  26. Configuration = configuration;
  27. }
  28. public IConfiguration Configuration { get; }
  29. // This method gets called by the runtime. Use this method to add services to the container.
  30. public void ConfigureServices(IServiceCollection services)
  31. {
  32. /*
  33. services.AddControllers();
  34. services.AddMemoryCache();
  35. services.AddMvc(setupAction => {
  36. setupAction.EnableEndpointRouting = false;
  37. }).AddJsonOptions(jsonOptions =>
  38. {
  39. jsonOptions.JsonSerializerOptions.PropertyNamingPolicy = null;
  40. })
  41. .AddXmlSerializerFormatters()
  42. .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
  43. */
  44. services.AddMvc(setupAction => {
  45. setupAction.EnableEndpointRouting = false;
  46. }).AddJsonOptions(jsonOptions =>
  47. {
  48. jsonOptions.JsonSerializerOptions.PropertyNamingPolicy = null;
  49. })
  50. .AddXmlSerializerFormatters()
  51. .SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
  52. services.Configure<KestrelServerOptions>(options =>
  53. {
  54. options.Limits.MaxRequestBodySize = int.MaxValue; // if don't set default value is: 30 MB
  55. });
  56. //string conn = Common.GetValuesAppSetting("api", "Connection");
  57. //services.AddDbContext<ModelContext>(options => options.UseOracle(conn));
  58. Variable.LoadConfigData();
  59. }
  60. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  61. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  62. {
  63. if (env.IsDevelopment())
  64. {
  65. app.UseDeveloperExceptionPage();
  66. }
  67. app.UseHttpsRedirection();
  68. app.UseRouting();
  69. app.UseAuthorization();
  70. app.UseEndpoints(endpoints =>
  71. {
  72. endpoints.MapControllers();
  73. });
  74. }
  75. }
  76. }