1212using Microsoft . Net . Http . Headers ;
1313using WebApiContrib . Core . Formatter . Csv ;
1414using Microsoft . AspNetCore . Mvc ;
15+ using Microsoft . Extensions . Hosting ;
1516
1617namespace ImportExportLocalization
1718{
1819 public class Startup
1920 {
20- public Startup ( IHostingEnvironment env )
21+ public Startup ( IConfiguration configuration )
2122 {
22- var builder = new ConfigurationBuilder ( )
23- . SetBasePath ( env . ContentRootPath )
24- . AddJsonFile ( "appsettings.json" , optional : true , reloadOnChange : true )
25- . AddJsonFile ( $ "appsettings.{ env . EnvironmentName } .json", optional : true )
26- . AddEnvironmentVariables ( ) ;
27- Configuration = builder . Build ( ) ;
23+ Configuration = configuration ;
2824 }
2925
30- public IConfigurationRoot Configuration { get ; }
26+ public IConfiguration Configuration { get ; }
3127
3228 // This method gets called by the runtime. Use this method to add services to the container.
3329 public void ConfigureServices ( IServiceCollection services )
@@ -46,7 +42,8 @@ public void ConfigureServices(IServiceCollection services)
4642 // Requires that LocalizationModelContext is defined
4743 services . AddSqlLocalization ( options => options . UseTypeFullNames = true ) ;
4844
49- services . AddMvc ( )
45+ services . AddControllersWithViews ( )
46+ . AddNewtonsoftJson ( )
5047 . AddViewLocalization ( )
5148 . AddDataAnnotationsLocalization ( ) ;
5249
@@ -72,13 +69,13 @@ public void ConfigureServices(IServiceCollection services)
7269 options . InputFormatters . Add ( new CsvInputFormatter ( csvFormatterOptions ) ) ;
7370 options . OutputFormatters . Add ( new CsvOutputFormatter ( csvFormatterOptions ) ) ;
7471 options . FormatterMappings . SetMediaTypeMappingForFormat ( "csv" , MediaTypeHeaderValue . Parse ( "text/csv" ) ) ;
75- } ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_2 ) ;
72+ } ) . SetCompatibilityVersion ( CompatibilityVersion . Version_3_0 ) ;
7673
7774 services . AddScoped < ValidateMimeMultipartContentFilter > ( ) ;
7875 }
7976
8077 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
81- public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
78+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
8279 {
8380 var locOptions = app . ApplicationServices . GetService < IOptions < RequestLocalizationOptions > > ( ) ;
8481 app . UseRequestLocalization ( locOptions . Value ) ;
@@ -92,13 +89,16 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
9289 app . UseExceptionHandler ( "/Home/Error" ) ;
9390 }
9491
92+ app . UseDefaultFiles ( ) ;
9593 app . UseStaticFiles ( ) ;
9694
97- app . UseMvc ( routes =>
95+ app . UseRouting ( ) ;
96+
97+ app . UseEndpoints ( endpoints =>
9898 {
99- routes . MapRoute (
99+ endpoints . MapControllerRoute (
100100 name : "default" ,
101- template : "{controller=Home}/{action=Index}/{id?}" ) ;
101+ pattern : "{controller=Home}/{action=Index}/{id?}" ) ;
102102 } ) ;
103103 }
104104 }
0 commit comments