DocSpace-client/web/ASC.Web.Studio/Startup.cs

83 lines
2.5 KiB
C#
Raw Normal View History

2019-09-10 12:42:15 +00:00
using ASC.Api.Core.Auth;
2019-06-06 08:44:38 +00:00
using ASC.Common.DependencyInjection;
2019-06-04 14:43:20 +00:00
using ASC.Data.Storage;
2019-06-10 12:54:10 +00:00
using ASC.Data.Storage.Configuration;
2019-07-09 10:29:53 +00:00
using Microsoft.AspNetCore.Authentication;
2019-05-15 14:56:09 +00:00
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
2019-07-12 14:28:14 +00:00
using Microsoft.AspNetCore.HttpOverrides;
2019-05-15 14:56:09 +00:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace ASC.Web.Studio
{
public class Startup
{
public IConfiguration Configuration { get; }
public IHostEnvironment HostEnvironment { get; }
public Startup(IConfiguration configuration, IHostEnvironment hostEnvironment)
2019-05-15 14:56:09 +00:00
{
Configuration = configuration;
HostEnvironment = hostEnvironment;
2019-05-15 14:56:09 +00:00
}
public void ConfigureServices(IServiceCollection services)
{
services.AddCors();
2019-06-04 14:43:20 +00:00
2019-06-06 13:34:46 +00:00
services.AddMvc();
services.AddMemoryCache();
2019-06-07 08:59:07 +00:00
services.AddDistributedMemoryCache();
services.AddSession();
2019-06-06 13:34:46 +00:00
2019-05-15 14:56:09 +00:00
/*services.AddMvc(options => options.EnableEndpointRouting = false)
.AddNewtonsoftJson();*/
services.AddAutofac(Configuration, HostEnvironment.ContentRootPath);
2019-06-10 16:15:34 +00:00
2019-07-09 10:29:53 +00:00
services.AddAuthentication("cookie").AddScheme<AuthenticationSchemeOptions, CookieAuthHandler>("cookie", a => { });
2019-06-06 08:44:38 +00:00
services.AddHttpContextAccessor()
2019-10-31 11:28:30 +00:00
.AddStorage();
2019-05-15 14:56:09 +00:00
}
// 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");
}
2019-06-04 14:43:20 +00:00
2019-07-12 14:28:14 +00:00
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
2019-06-04 14:43:20 +00:00
app.UseRouting();
2019-05-15 14:56:09 +00:00
2019-05-30 07:33:38 +00:00
app.UseCors(builder =>
builder
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod());
2019-05-15 14:56:09 +00:00
2019-07-09 13:07:44 +00:00
app.UseStaticFiles();
2019-06-07 08:59:07 +00:00
app.UseSession();
2019-07-09 10:29:53 +00:00
app.UseAuthentication();
2019-06-04 14:43:20 +00:00
app.UseEndpoints(endpoints =>
{
endpoints.InitializeHttpHandlers();
2019-05-15 14:56:09 +00:00
});
}
}
}