2018-02-21 20:29:23 -05:00
|
|
|
|
using System;
|
2018-04-04 15:38:34 -04:00
|
|
|
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
|
|
|
|
|
namespace WebfrontCore
|
|
|
|
|
{
|
|
|
|
|
public class Startup
|
|
|
|
|
{
|
|
|
|
|
public Startup(IHostingEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
var builder = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(env.ContentRootPath)
|
2018-03-14 01:36:25 -04:00
|
|
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
2018-02-21 20:29:23 -05:00
|
|
|
|
.AddEnvironmentVariables();
|
|
|
|
|
Configuration = builder.Build();
|
|
|
|
|
|
2018-03-18 22:25:11 -04:00
|
|
|
|
if (!IW4MAdmin.Program.Start())
|
|
|
|
|
Environment.Exit(-1);
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 03:01:12 -05:00
|
|
|
|
public static IConfigurationRoot Configuration { get; private set; }
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
|
{
|
|
|
|
|
// Add framework services.
|
|
|
|
|
services.AddMvc();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
|
|
|
{
|
|
|
|
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
|
|
|
|
loggerFactory.AddDebug();
|
|
|
|
|
|
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
|
{
|
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
|
app.UseBrowserLink();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
app.UseExceptionHandler("/Home/Error");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
app.UseStaticFiles();
|
|
|
|
|
|
2018-04-04 15:38:34 -04:00
|
|
|
|
app.UseCookieAuthentication(new CookieAuthenticationOptions()
|
|
|
|
|
{
|
|
|
|
|
AccessDeniedPath = "/Account/Login/",
|
|
|
|
|
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
|
|
|
|
|
AutomaticAuthenticate = true,
|
|
|
|
|
AutomaticChallenge = true,
|
|
|
|
|
LoginPath = "/Account/Login/"
|
|
|
|
|
});
|
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
app.UseMvc(routes =>
|
|
|
|
|
{
|
|
|
|
|
routes.MapRoute(
|
|
|
|
|
name: "default",
|
|
|
|
|
template: "{controller=Home}/{action=Index}/{id?}");
|
|
|
|
|
});
|
2018-04-04 15:38:34 -04:00
|
|
|
|
|
|
|
|
|
//app.UseBasicAuthentication(Authentication.Basic.Generate());
|
2018-02-21 20:29:23 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|