123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using CZFW.Core;
- using CZFW.Framework;
- using CZFW.Framework.Model;
- using CZFW.MDB;
- using CZFW.MDB.Util;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.AspNetCore.Hosting;
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.HttpOverrides;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.EntityFrameworkCore;
- using Microsoft.Extensions.Configuration;
- using Microsoft.Extensions.DependencyInjection;
- using Microsoft.Extensions.Logging;
- namespace CZFW.CMS.Builder
- {
- public class Startup
- {
- public Startup(IConfiguration configuration)
- {
- Configuration = configuration;
- ConfigHelper.Configs = configuration;
- }
- public IConfiguration Configuration { get; }
-
- public void ConfigureServices(IServiceCollection services)
- {
-
-
-
-
-
-
-
-
-
- services.ConfigureFrameworkServices();
- services.ConfigureMDBServices();
- services.AddMemoryCache();
- services.AddSession(options =>
- {
- options.Cookie.Name = "_sid__";
- options.IdleTimeout = TimeSpan.FromMinutes(60);
- });
- services.AddCors(Options =>
- {
- Options.AddPolicy("any", builder =>
- {
- builder.AllowAnyHeader()
- .AllowAnyMethod()
- .AllowAnyOrigin()
- .AllowCredentials();
- });
- });
- services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
- CZHttpContext.ServiceProvider = services.BuildServiceProvider();
- }
-
- public void Configure(IApplicationBuilder app, IHostingEnvironment env)
- {
-
- if (env.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- else
- {
- app.UseExceptionHandler("/Home/Error");
- }
- app.UseStaticFiles();
- app.UseCookiePolicy();
- app.UseForwardedHeaders(new ForwardedHeadersOptions
- {
- ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
- });
- app.UseSession();
- app.UseMvc(routes =>
- {
- routes.MapRoute(
- name: "resource", template: $"{Constants.RESOURCE_FILE_URL_PREFIX}/{{siteId}}/{{fileType}}/{{fileName}}",
- defaults: new { controller = "Resource", action = "Load" });
- routes.MapRoute(
- name: "content", template: $"{Constants.CONTENT_FILE_URL_PREFIX}/{{tplId}}/{{theme}}/{{folder}}/{{typeFolder}}/{{fileName}}",
- defaults: new { controller = "Resource", action = "Content" });
- routes.MapRoute(
- name: "default",
- template: "{controller=Home}/{action=Index}/{id?}");
- });
- }
- }
- }
|