66 lines
1.5 KiB
C#
66 lines
1.5 KiB
C#
using Photon.Core.Redis;
|
||
|
||
|
||
var builder = WebApplication.CreateBuilder(args);
|
||
|
||
builder.Services.Inject(new List<string> {
|
||
"Application.Web.Admin","Application.Domain"
|
||
});//框架初始化
|
||
|
||
builder.Configuration.RegisterConfig();//注入配置
|
||
builder.Services.InjectRedis(builder.Configuration);
|
||
builder.Services.InjectSql(builder.Configuration);
|
||
|
||
//日志
|
||
builder.Logging.InjectLog();
|
||
// Add services to the container.
|
||
|
||
|
||
// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi
|
||
|
||
#region 配置跨域处理,允许所有来源
|
||
|
||
builder.Services.AddCors(options =>
|
||
{
|
||
options.AddPolicy("all", builder =>
|
||
{
|
||
builder.AllowAnyOrigin() //允许任何来源的主机访问
|
||
.AllowAnyMethod()
|
||
.AllowAnyHeader();
|
||
});
|
||
});
|
||
|
||
#endregion 配置跨域处理,允许所有来源
|
||
|
||
|
||
builder.Services.AddSignalR();
|
||
|
||
var app = builder.Build();
|
||
|
||
app.Services.UseInject();//启用框架
|
||
app.Configuration.UseConfig();//启用配置
|
||
|
||
// Configure the HTTP request pipeline.
|
||
if (app.Environment.IsDevelopment())
|
||
{
|
||
app.UseExceptionHandler("/Home/Error");
|
||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
|
||
app.UseHsts();
|
||
}
|
||
|
||
app.UseCors("all");
|
||
app.UseStaticFiles();
|
||
app.UseHttpsRedirection();
|
||
|
||
app.UseAuthentication();
|
||
app.UseAuthorization();
|
||
|
||
app.MapControllers();
|
||
app.MapControllerRoute(
|
||
name: "default",
|
||
pattern: "{controller=Index}/{action=Index}/{id?}")
|
||
.WithStaticAssets();
|
||
|
||
SnowflakeAssist.Initialize(0, 0);
|
||
app.Run();
|