55using Microsoft . EntityFrameworkCore ;
66using Microsoft . Extensions . Configuration ;
77using Microsoft . Extensions . DependencyInjection ;
8+ using Microsoft . Extensions . Hosting ;
89
910namespace 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