centos 7
.net core sdk 已安装
运行 dotnet xxx.dll 一直没反应
一直卡在这里
代码如下
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseUrls("http://*:9001");
webBuilder.UseStartup<Startup>();
});
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
services.AddControllersWithViews();
//加载appsettings
services.AddSingleton(new AppSettings(Env.ContentRootPath));
//var MySecretKey = Appsettings.app(new string[] { "WebConfig", "MySecretKey" });
services.AddDistributedMemoryCache();
services.AddSession();
services.AddDbContext<EFCoreDBContext>(options =>
{
options.UseSqlServer(Configuration.GetConnectionString("ConnConnection"));
});
services.AddScoped<IEFCoreDBContext, EFCoreDBContext>();
services.AddScoped<IRepositoryFactory, RepositoryFactory>();
services.AddScoped<IBaseService, BaseService>();
services.AddScoped<ISysUserService, SysUserService>();
services.AddScoped<ISysMenuService, SysMenuService>();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(opt => { opt.LoginPath = new PathString("/Login/Index/"); });
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseSession();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
//endpoints.MapRazorPages();使用pages文件夹
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Login}/{action=Index}/{id?}");
});
}