using Longbow.Web; using Longbow.Web.SignalR; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using System; namespace Bootstrap.Client { /// /// /// public class Startup { /// /// /// /// public Startup(IConfiguration configuration) { Configuration = configuration; } /// /// /// public IConfiguration Configuration { get; } // This method gets called by the runtime. Use this method to add services to the container. /// /// /// /// public void ConfigureServices(IServiceCollection services) { services.Configure(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.AddCors(); services.AddLogging(builder => builder.AddFileLogger()); services.AddConfigurationManager(); services.AddCacheManager(); services.AddDbAdapter(); services.AddSignalR().AddJsonProtocalDefault(); services.AddResponseCompression(); services.AddBootstrapAdminAuthentication(); services.AddMvc(options => { options.Filters.Add(); options.Filters.Add(); }).AddJsonOptions(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; JsonConvert.DefaultSettings = () => options.SerializerSettings; }).SetCompatibilityVersion(CompatibilityVersion.Version_2_2); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. /// /// /// /// /// public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); app.UseHsts(); } app.UseStatusCodePagesWithReExecute("/Home/Error/{0}"); app.UseCors(builder => builder.WithOrigins(Configuration["AllowOrigins"].Split(',', StringSplitOptions.RemoveEmptyEntries)).AllowAnyHeader().AllowAnyMethod().AllowCredentials()); app.UseHttpsRedirection(); app.UseResponseCompression(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseBootstrapAdminAuthentication(); app.UseCacheManager(); app.UseSignalR(routes => { routes.MapHub("/NotiHub"); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); } } }