@ -1,16 +1,16 @@
using IRepository ;
using IServices ;
using MediatR ;
using Microsoft.AspNetCore.Authentication.Cookies ;
using Microsoft.AspNetCore.Builder ;
using Microsoft.AspNetCore.Hosting ;
using Microsoft.AspNetCore.HttpOverrides ;
using Microsoft.AspNetCore.Mvc ;
using Microsoft.Extensions.Configuration ;
using Microsoft.Extensions.DependencyInjection ;
using Microsoft.Extensions.Hosting ;
using Repository ;
using Services ;
using SqlSugar ;
using System ;
using System.Text ;
using YL.Core.Orm.SqlSugar ;
using YL.NetCore.Attributes ;
@ -18,10 +18,6 @@ using YL.NetCore.Conventions;
using YL.NetCore.DI ;
using YL.NetCoreApp.Extensions ;
using YL.Utils.Json ;
using MediatR ;
using Microsoft.Extensions.DependencyInjection.Extensions ;
using Microsoft.AspNetCore.Mvc.Controllers ;
using Microsoft.AspNetCore.Mvc.Filters ;
namespace YL
{
@ -41,18 +37,27 @@ namespace YL
{
option . Filters . Add < BaseExceptionAttribute > ( ) ;
//option.Filters.Add<FilterXSSAttribute>();
option . Conventions . Add ( new ApplicationDescription ( "keywords" , Configuration [ "sys:keywords" ] ) ) ;
option . Conventions . Add ( new ApplicationDescription ( "description" , Configuration [ "sys:description" ] ) ) ;
option . Conventions . Add ( new ApplicationDescription ( "title" , Configuration [ "sys:title" ] ) ) ;
option . Conventions . Add ( new ApplicationDescription ( "company" , Configuration [ "sys:company" ] ) ) ;
option . Conventions . Add ( new ApplicationDescription ( "customer" , Configuration [ "sys:customer" ] ) ) ;
} ) . SetCompatibilityVersion ( CompatibilityVersion . Latest ) ;
services . AddControllersWithViews ( ) ;
services . AddRazorPages ( ) . AddRazorRuntimeCompilation ( ) ;
//services.AddControllersWithViews(option =>
//{
// option.Filters.Add<BaseExceptionAttribute>();
// //option.Filters.Add<FilterXSSAttribute>();
// option.Conventions.Add(new ApplicationDescription("title", Configuration["sys:title"]));
// option.Conventions.Add(new ApplicationDescription("company", Configuration["sys:company"]));
// option.Conventions.Add(new ApplicationDescription("customer", Configuration["sys:customer"]));
//});
//services.Configure<CookiePolicyOptions>(options =>
//{
// // This lambda determines whether user consent for non-essential cookies is needed for a given request.
// options.CheckConsentNeeded = context => true;
// options.MinimumSameSitePolicy = SameSiteMode.None;
//});
services . AddTimedJob ( ) ;
// services.AddTimedJob() ;
services . AddOptions ( ) ;
services . AddXsrf ( ) ;
services . AddXss ( ) ;
@ -84,7 +89,6 @@ namespace YL
{
o . JsonType = JsonType . Jil ;
} ) ;
services . AddDIProperty ( ) ;
services . AddHttpContextAccessor ( ) ;
services . AddHtmlEncoder ( ) ;
Encoding . RegisterProvider ( CodePagesEncodingProvider . Instance ) ;
@ -98,8 +102,8 @@ namespace YL
RegisterBase ( services ) ;
ServiceExtension . RegisterAssembly ( services , "Services" ) ;
ServiceExtension . RegisterAssembly ( services , "Repository" ) ;
var bulid = services . BuildServiceProvider ( ) ;
ServiceResolve . SetServiceResolve ( bulid ) ;
//var bulid = services.BuildServiceProvider() ;
//ServiceResolve.SetServiceResolve(bulid) ;
}
/// <summary>
@ -129,7 +133,7 @@ namespace YL
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure ( IApplicationBuilder app , I Hosting Environment env )
public void Configure ( IApplicationBuilder app , I Web HostEnvironment env )
{
if ( env . IsDevelopment ( ) )
{
@ -139,28 +143,31 @@ namespace YL
{
app . UseExceptionHandler ( "/Home/Error" ) ;
}
app . UseStaticFiles ( ) ; //使用静态文件
app . UseGlobalCore ( ) ;
app . UseExecuteTime ( ) ;
app . UseTimedJob ( ) ;
// app.UseTimedJob() ;
app . UseResponseCompression ( ) ; //使用压缩
app . UseResponseCaching ( ) ; //使用缓存
app . UseStaticFiles ( ) ; //使用静态文件
app . UseCookiePolicy ( ) ;
app . UseRouting ( ) ;
app . UseAuthentication ( ) ;
app . UseAuthorization ( ) ;
app . UseStatusCodePagesWithRedirects ( "/Home/Error/{0}" ) ;
app . UseMvc ( routes = >
app . UseEndpoints ( endpoints = >
{
routes. Map Route(
name : "default" ,
template : "{controller=Login }/{action=Index}/{id?}") ;
// Areas
routes. Map Route(
endpoints. MapController Route(
name : "default" ,
pattern : "{controller=Home }/{action=Index}/{id?}") ;
endpoints. MapAreaController Route(
name : "areas" ,
template : "{area:exists}/{controller=Home}/{action=Index}/{id?}"
) ;
areaName : "areas" ,
pattern : "{area:exists}/{controller=Home}/{action=Index}/{id?}" ) ;
endpoints . MapRazorPages ( ) ;
} ) ;
}
}