44using System . Threading . Tasks ;
55using Microsoft . AspNetCore . Builder ;
66using Microsoft . AspNetCore . Hosting ;
7- using Microsoft . AspNetCore . Identity . EntityFrameworkCore ;
8- using Microsoft . EntityFrameworkCore ;
7+ // using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
8+ // using Microsoft.EntityFrameworkCore;
99using Microsoft . Extensions . Configuration ;
1010using Microsoft . Extensions . DependencyInjection ;
1111using Microsoft . Extensions . Logging ;
1515using Microsoft . Extensions . Options ;
1616using Microsoft . Extensions . Localization ;
1717using cloudscribe . Web . Localization ;
18+ using Microsoft . Extensions . Hosting ;
1819
1920//https://github.com/aspnet/Localization/issues/157
2021
@@ -23,7 +24,7 @@ namespace localization.WebApp
2324 public class Startup
2425 {
2526
26- public Startup ( IConfiguration configuration , IHostingEnvironment env )
27+ public Startup ( IConfiguration configuration )
2728 {
2829 Configuration = configuration ;
2930
@@ -34,6 +35,10 @@ public Startup(IConfiguration configuration, IHostingEnvironment env)
3435 // This method gets called by the runtime. Use this method to add services to the container.
3536 public void ConfigureServices ( IServiceCollection services )
3637 {
38+
39+ services . AddControllersWithViews ( ) ;
40+ services . AddRazorPages ( ) ;
41+
3742 services . Configure < GlobalResourceOptions > ( Configuration . GetSection ( "GlobalResourceOptions" ) ) ;
3843 services . AddSingleton < IStringLocalizerFactory , GlobalResourceManagerStringLocalizerFactory > ( ) ;
3944 //services.AddSingleton<IStringLocalizerFactory, PatchedResourceManagerStringLocalizerFactory>();
@@ -44,7 +49,7 @@ public void ConfigureServices(IServiceCollection services)
4449 services . AddMvc ( )
4550 . AddRazorOptions ( options =>
4651 {
47- options . AddEmbeddedViewsForWebLib ( ) ;
52+ // options.AddEmbeddedViewsForWebLib();
4853 } )
4954 . AddViewLocalization ( LanguageViewLocationExpanderFormat . Suffix )
5055 . AddDataAnnotationsLocalization ( )
@@ -96,17 +101,16 @@ public void ConfigureServices(IServiceCollection services)
96101
97102 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
98103 public void Configure (
99- IApplicationBuilder app ,
100- IHostingEnvironment env ,
101- ILoggerFactory loggerFactory ,
104+ IApplicationBuilder app ,
105+ IWebHostEnvironment env ,
102106 IOptions < RequestLocalizationOptions > locOptions
103107 )
104108 {
105109
106110 if ( env . IsDevelopment ( ) )
107111 {
108112 app . UseDeveloperExceptionPage ( ) ;
109- app . UseDatabaseErrorPage ( ) ;
113+ // app.UseDatabaseErrorPage();
110114
111115 }
112116 else
@@ -119,23 +123,44 @@ IOptions<RequestLocalizationOptions> locOptions
119123
120124 app . UseRequestLocalization ( locOptions . Value ) ;
121125
122- // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715
123-
126+ app . UseHttpsRedirection ( ) ;
127+ app . UseStaticFiles ( ) ;
124128
125- app . UseMvc ( routes =>
126- {
127- routes . MapRoute (
128- name : "default-localized" ,
129- template : "{culture}/{controller}/{action}/{id?}" ,
130- defaults : new { controller = "Home" , action = "Index" } ,
131- constraints : new { culture = new CultureSegmentRouteConstraint ( ) }
132- ) ;
129+ app . UseRouting ( ) ;
133130
131+ app . UseAuthentication ( ) ;
132+ app . UseAuthorization ( ) ;
134133
135- routes . MapRoute (
134+ app . UseEndpoints ( endpoints =>
135+ {
136+ endpoints . MapControllerRoute (
137+ name : "default-localized" ,
138+ pattern : "{culture}/{controller}/{action}/{id?}" ,
139+ defaults : new { controller = "Home" , action = "Index" } ,
140+ constraints : new { culture = new CultureSegmentRouteConstraint ( ) }
141+ ) ;
142+
143+ endpoints . MapControllerRoute (
136144 name : "default" ,
137- template : "{controller=Home}/{action=Index}/{id?}" ) ;
145+ pattern : "{controller=Home}/{action=Index}/{id?}" ) ;
146+ endpoints . MapRazorPages ( ) ;
138147 } ) ;
148+
149+
150+ //app.UseMvc(routes =>
151+ //{
152+ // routes.MapRoute(
153+ // name: "default-localized",
154+ // template: "{culture}/{controller}/{action}/{id?}",
155+ // defaults: new { controller = "Home", action = "Index" },
156+ // constraints: new { culture = new CultureSegmentRouteConstraint() }
157+ // );
158+
159+
160+ // routes.MapRoute(
161+ // name: "default",
162+ // template: "{controller=Home}/{action=Index}/{id?}");
163+ //});
139164 }
140165 }
141166}
0 commit comments