Commit b7e3071c by guanzhenshan

netcore2.1升级到3.1

parent 37dcbea8
<Project Sdk="Microsoft.NET.Sdk.Web"> <Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<PackageReference Include="Bailun.ServiceFabric.Core" Version="1.1.0" /> <PackageReference Include="Bailun.ServiceFabric.Core" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.7" /> <PackageReference Include="Microsoft.AspNetCore" Version="2.1.7" />
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" /> <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" /> <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.14" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.14" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.14" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.14" />
......
...@@ -3,7 +3,7 @@ WORKDIR /app ...@@ -3,7 +3,7 @@ WORKDIR /app
EXPOSE 80 EXPOSE 80
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
FROM microsoft/dotnet:2.1-sdk AS build FROM microsoft/dotnet:3.1-sdk AS build
WORKDIR /src WORKDIR /src
COPY Bailun.DC.Web/Bailun.DC.Web.csproj Bailun.DC.Web/ COPY Bailun.DC.Web/Bailun.DC.Web.csproj Bailun.DC.Web/
COPY Bailun.DC.Services/Bailun.DC.Services.csproj Bailun.DC.Services/ COPY Bailun.DC.Services/Bailun.DC.Services.csproj Bailun.DC.Services/
......
...@@ -6,6 +6,7 @@ using System.Threading.Tasks; ...@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
namespace Bailun.DC.Web namespace Bailun.DC.Web
...@@ -14,20 +15,28 @@ namespace Bailun.DC.Web ...@@ -14,20 +15,28 @@ namespace Bailun.DC.Web
{ {
public static void Main(string[] args) public static void Main(string[] args)
{ {
CreateWebHostBuilder(args).Build().Run(); CreateHostBuilder(args).Build().Run();
} }
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args) public static IHostBuilder CreateHostBuilder(string[] args) =>
.UseKestrel(options => Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{ {
options.Limits.MaxRequestBodySize = 200*1024*1024; // 200M webBuilder.UseStartup<Startup>();
}) });
//.UseHttpSys(options =>
//{ //public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
// options.MaxRequestBodySize = 100_000_000; // WebHost.CreateDefaultBuilder(args)
//}) // .UseKestrel(options =>
.UseStartup<Startup>() // {
; // options.Limits.MaxRequestBodySize = 200*1024*1024; // 200M
// })
// //.UseHttpSys(options =>
// //{
// // options.MaxRequestBodySize = 100_000_000;
// //})
// .UseStartup<Startup>()
// ;
} }
} }
...@@ -51,15 +51,18 @@ namespace Bailun.DC.Web ...@@ -51,15 +51,18 @@ namespace Bailun.DC.Web
//注入session服务 //注入session服务
//services.AddSession(); //services.AddSession();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddControllersWithViews().AddMvcOptions(options => {
options.EnableEndpointRouting = false;
}).SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>(); services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All)); services.AddSingleton(HtmlEncoder.Create(UnicodeRanges.All));
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env) public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{ {
if (env.IsDevelopment()) if (env.EnvironmentName=="DEBUG")
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment