diff --git a/Dockerfile b/Dockerfile index 738cc13..bd9f44a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,11 +1,11 @@ -FROM mcr.microsoft.com/dotnet/aspnet:2.1 AS base +FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base WORKDIR /app EXPOSE 80 ENV SYNCFUSION_LICENSE_KEY="" ENV SPELLCHECK_DICTIONARY_PATH="" ENV SPELLCHECK_JSON_FILENAME="" ENV SPELLCHECK_CACHE_COUNT="" -FROM mcr.microsoft.com/dotnet/sdk:2.1 AS build +FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /source COPY ["src/ej2-documenteditor-server/ej2-documenteditor-server.csproj", "./ej2-documenteditor-server/ej2-documenteditor-server.csproj"] diff --git a/src/ej2-documenteditor-server/Startup.cs b/src/ej2-documenteditor-server/Startup.cs index c791b55..b4b0910 100644 --- a/src/ej2-documenteditor-server/Startup.cs +++ b/src/ej2-documenteditor-server/Startup.cs @@ -9,7 +9,6 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Microsoft.EntityFrameworkCore; -using Microsoft.Data.Edm; using Microsoft.AspNet.OData.Builder; using Microsoft.AspNet.OData.Extensions; using Microsoft.AspNetCore.Routing; @@ -19,6 +18,8 @@ using Syncfusion.EJ2.SpellChecker; using System.IO; using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Microsoft.AspNetCore.ResponseCompression; namespace EJ2DocumentEditorServer { @@ -63,27 +64,30 @@ public Startup(IConfiguration configuration, IHostingEnvironment env) } public IConfiguration Configuration { get; } - + readonly string MyAllowSpecificOrigins = "MyPolicy"; // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddOData(); - services.AddMvc().AddJsonOptions(x => { - x.SerializerSettings.ContractResolver = null; + services.AddControllers(); + services.AddMemoryCache(); + services.AddControllers().AddNewtonsoftJson(options => + { + // Use the default property (Pascal) casing + options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); services.AddCors(options => { - options.AddPolicy("AllowAllOrigins", builder => + options.AddPolicy(MyAllowSpecificOrigins, + builder => { builder.AllowAnyOrigin() - .AllowAnyMethod() - .AllowAnyHeader(); + .AllowAnyMethod() + .AllowAnyHeader(); }); }); - - // Add framework services. - services.AddMvc(); + services.Configure(options => options.Level = System.IO.Compression.CompressionLevel.Optimal); + services.AddResponseCompression(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -98,10 +102,18 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseDeveloperExceptionPage(); } - - app.UseMvc(routes => + else + { + app.UseHsts(); + } + app.UseHttpsRedirection(); + app.UseRouting(); + app.UseAuthorization(); + app.UseCors(MyAllowSpecificOrigins); + app.UseResponseCompression(); + app.UseEndpoints(endpoints => { - routes.MapRoute("default", "{api}/{controller}/{action}/{id?}"); + endpoints.MapControllers().RequireCors("MyPolicy"); }); } diff --git a/src/ej2-documenteditor-server/ej2-documenteditor-server.csproj b/src/ej2-documenteditor-server/ej2-documenteditor-server.csproj index 754d561..f8092ca 100644 --- a/src/ej2-documenteditor-server/ej2-documenteditor-server.csproj +++ b/src/ej2-documenteditor-server/ej2-documenteditor-server.csproj @@ -1,7 +1,7 @@  - netcoreapp2.1 + net6.0 false Linux ..\docker-compose.dcproj @@ -34,19 +34,16 @@ - - - - - + + - + diff --git a/src/ej2-documenteditor-server/web.config b/src/ej2-documenteditor-server/web.config index a130cac..2d9ed3f 100644 --- a/src/ej2-documenteditor-server/web.config +++ b/src/ej2-documenteditor-server/web.config @@ -10,9 +10,9 @@ - + - +