Skip to content

Commit caf12d8

Browse files
authored
Merge pull request #8 from damienbod/dev_3_0
Dev 3 0
2 parents f7f53a3 + 31bab2d commit caf12d8

4 files changed

Lines changed: 32 additions & 17 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
# ASP.NET Core 2.2 MVC file upload / download with MS SQL Server FileTable
1+
# ASP.NET Core 3.0 MVC file upload / download with MS SQL Server FileTable
22

33
https://damienbod.com/2015/12/05/asp-net-5-mvc-6-file-upload-with-ms-sql-server-filetable/
44

55
## History
66

7+
2019-10-05 Updated to .NET Core 3.0
8+
79
2019-06-16 Updated to .NET Core packages, npm packages, in process hosting
810

911
2018-12-05 Updated to .NET Core 2.2

src/AspNetCoreFileUploadFileTable/AspNetCoreFileUploadFileTable.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.2</TargetFramework>
3+
<TargetFramework>netcoreapp3.0</TargetFramework>
44
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
55
</PropertyGroup>
66

@@ -10,9 +10,9 @@
1010

1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.AspNetCore.App" />
13-
<PackageReference Include="BuildBundlerMinifier" Version="2.9.406" />
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.4" />
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.4">
13+
<PackageReference Include="BuildBundlerMinifier" Version="3.0.415" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0">
1616
<PrivateAssets>all</PrivateAssets>
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1818
</PackageReference>
Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
1-
using Microsoft.AspNetCore;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
25
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
39

410
namespace AspNetCoreFileUploadFileTable
511
{
612
public class Program
713
{
814
public static void Main(string[] args)
915
{
10-
CreateWebHostBuilder(args).Build().Run();
16+
CreateHostBuilder(args).Build().Run();
1117
}
1218

13-
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
14-
WebHost.CreateDefaultBuilder(args)
15-
.UseStartup<Startup>();
19+
public static IHostBuilder CreateHostBuilder(string[] args) =>
20+
Host.CreateDefaultBuilder(args)
21+
.ConfigureWebHostDefaults(webBuilder =>
22+
{
23+
webBuilder.UseStartup<Startup>();
24+
});
1625
}
1726
}

src/AspNetCoreFileUploadFileTable/Startup.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
using Microsoft.EntityFrameworkCore;
66
using Microsoft.Extensions.Configuration;
77
using Microsoft.Extensions.DependencyInjection;
8+
using Microsoft.Extensions.Hosting;
89

910
namespace AspNetCoreFileUploadFileTable
1011
{
1112
public class Startup
1213
{
13-
private readonly IHostingEnvironment _environment;
14+
private readonly IWebHostEnvironment _environment;
1415

15-
public Startup(IHostingEnvironment env, IConfiguration configuration)
16+
public Startup(IWebHostEnvironment env, IConfiguration configuration)
1617
{
1718
Configuration = configuration;
1819
_environment = env;
@@ -33,13 +34,14 @@ public void ConfigureServices(IServiceCollection services)
3334
)
3435
);
3536

36-
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
37+
services.AddControllersWithViews()
38+
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
3739

3840
services.AddScoped<IFileRepository, FileRepository>();
3941
services.AddScoped<ValidateMimeMultipartContentFilter>();
4042
}
4143

42-
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
44+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
4345
{
4446
if (env.IsDevelopment())
4547
{
@@ -52,11 +54,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
5254

5355
app.UseStaticFiles();
5456

55-
app.UseMvc(routes =>
57+
app.UseRouting();
58+
59+
app.UseEndpoints(endpoints =>
5660
{
57-
routes.MapRoute(
61+
endpoints.MapControllerRoute(
5862
name: "default",
59-
template: "{controller=FileClient}/{action=ViewAllFiles}/{id?}");
63+
pattern: "{controller=FileClient}/{action=ViewAllFiles}/{id?}");
6064
});
6165
}
6266
}

0 commit comments

Comments
 (0)