本文整理汇总了C#中IApplicationBuilder.UseRequestLocalization方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseRequestLocalization方法的具体用法?C# IApplicationBuilder.UseRequestLocalization怎么用?C# IApplicationBuilder.UseRequestLocalization使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseRequestLocalization方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseRequestLocalization(new RequestLocalizationOptions()
{
SupportedCultures = new List<CultureInfo>
{
new CultureInfo("fr"),
}
}, new RequestCulture("fr"));
app.UseMvc();
}
示例2: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
app.UseRequestLocalization(locOptions.Value);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例3: ConfigureRequestLocalization
protected virtual void ConfigureRequestLocalization(IApplicationBuilder app)
{
using (var languageManager = AbpBootstrapper.IocManager.ResolveAsDisposable<ILanguageManager>())
{
var supportedCultures = languageManager.Object
.GetLanguages()
.Select(l => new CultureInfo(l.Name))
.ToArray();
var defaultCulture = new RequestCulture(
languageManager.Object
.GetLanguages()
.FirstOrDefault(l => l.IsDefault)
?.Name
);
var options = new RequestLocalizationOptions
{
DefaultRequestCulture = defaultCulture,
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
};
app.UseRequestLocalization(options);
}
}
示例4: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
var requestLocalizationOptions = new RequestLocalizationOptions
{
SupportedCultures = new List<CultureInfo>
{
new CultureInfo("en-US"),
new CultureInfo("de-CH"),
new CultureInfo("fr-CH"),
new CultureInfo("it-CH")
},
SupportedUICultures = new List<CultureInfo>
{
new CultureInfo("en-US"),
new CultureInfo("de-CH"),
new CultureInfo("fr-CH"),
new CultureInfo("it-CH")
}
};
app.UseRequestLocalization(requestLocalizationOptions, new RequestCulture("en-US"));
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseMvc();
app.UseStaticFiles();
}
示例5: Configure
public void Configure(IApplicationBuilder app)
{
app.UseStatusCodePages();
app.UseFileServer();
if (_autoFac)
{
app.UseMiddleware<MonitoringMiddlware>();
}
app.UseRequestLocalization();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");
routes.MapRoute(
"controllerActionRoute",
"{controller}/{action}",
new { controller = "Home", action = "Index" },
constraints: null,
dataTokens: new { NameSpace = "default" });
routes.MapRoute(
"controllerRoute",
"{controller}",
new { controller = "Home" });
});
}
示例6: Configure
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole((category, level) =>
{
if (category.StartsWith("Microsoft."))
{
return level >= LogLevel.Information;
}
return level >= LogLevel.Verbose;
});
app.UseStatusCodePages();
app.UseFileServer();
app.UseRequestLocalization(new RequestCulture("en-US"));
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute("areaRoute", "{area:exists}/{controller}/{action}");
routes.MapRoute(
"controllerActionRoute",
"{controller}/{action}",
new { controller = "Home", action = "Index" },
constraints: null,
dataTokens: new { NameSpace = "default" });
routes.MapRoute(
"controllerRoute",
"{controller}",
new { controller = "Home" });
});
}
示例7: ConfigureRequestLocalization
private static void ConfigureRequestLocalization(IApplicationBuilder app)
{
using (var languageManager = app.ApplicationServices.GetRequiredService<IIocResolver>().ResolveAsDisposable<ILanguageManager>())
{
var defaultLanguage = languageManager.Object
.GetLanguages()
.FirstOrDefault(l => l.IsDefault);
if (defaultLanguage == null)
{
return;
}
var supportedCultures = languageManager.Object
.GetLanguages()
.Select(l => new CultureInfo(l.Name))
.ToArray();
var defaultCulture = new RequestCulture(defaultLanguage.Name);
var options = new RequestLocalizationOptions
{
DefaultRequestCulture = defaultCulture,
SupportedCultures = supportedCultures,
SupportedUICultures = supportedCultures
};
app.UseRequestLocalization(options);
}
}
示例8: Configure
public void Configure(IApplicationBuilder app)
{
app.UseRequestLocalization();
// Add MVC to the request pipeline
app.UseMvcWithDefaultRoute();
}
示例9: Configure
public void Configure(IApplicationBuilder app)
{
app.UseCultureReplacer();
app.UseRequestLocalization();
app.UseMvcWithDefaultRoute();
}
示例10: Configure
public void Configure(IApplicationBuilder app)
{
app.UseRequestLocalization(new RequestLocalizationOptions
{
// Ignore ambient and client locale. Use same values as ReplaceCultureAttribute / CultureReplacerMiddleware.
DefaultRequestCulture = new RequestCulture("en-GB", "en-US"),
RequestCultureProviders = new List<IRequestCultureProvider>()
});
app.UseMvc();
}
示例11: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
loggerFactory.AddDebug();
var locOptions = app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
app.UseRequestLocalization(locOptions.Value);
app.UseStaticFiles();
app.UseMvc();
}
示例12: Configure
public void Configure(IApplicationBuilder app)
{
// Default to en-CA locale and make sure nothing overrides that choice.
var options = new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("en-CA"),
};
options.RequestCultureProviders.Clear();
app.UseRequestLocalization(options);
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
}
示例13: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
// Configure the Localization middleware
var culture = new RequestCulture(new CultureInfo("en-US"), new CultureInfo("en-US"));
app.UseRequestLocalization(culture);
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
try
{
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
.CreateScope())
{
serviceScope.ServiceProvider.GetService<ApplicationDbContext>()
.Database.Migrate();
}
}
catch { }
}
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseStaticFiles();
app.UseIdentity();
// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例14: Configure
public void Configure(IApplicationBuilder applicationBuilder, IHostingEnvironment hostingEnvironment)
{
applicationBuilder.UseSession();
if (hostingEnvironment.IsEnvironment("Development"))
{
applicationBuilder.UseStatusCodePages();
applicationBuilder.UseErrorPage();
applicationBuilder.UseBrowserLink();
}
else
{
applicationBuilder.UseStatusCodePages();
applicationBuilder.UseErrorHandler("/Default/Error");
}
applicationBuilder.UseStaticFiles();
applicationBuilder.UseCookieAuthentication(options => {
options.AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.AutomaticAuthentication = true;
options.CookieName = "PLATFORMUS";
options.ExpireTimeSpan = new System.TimeSpan(1, 0, 0);
options.LoginPath = new PathString("/Backend/Account/SignIn");
});
RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions();
requestLocalizationOptions.RequestCultureProviders.Insert(0, new RouteValueRequestCultureProvider());
applicationBuilder.UseRequestLocalization(requestLocalizationOptions);
applicationBuilder.UseMvc(routes =>
{
// Backend
routes.MapRoute(name: "Backend Create", template: "{area:exists}/{controller=Default}/create", defaults: new { action = "CreateOrEdit" });
routes.MapRoute(name: "Backend Edit", template: "{area:exists}/{controller=Default}/edit/{id}", defaults: new { action = "CreateOrEdit" });
routes.MapRoute(name: "Backend Default", template: "{area:exists}/{controller=Default}/{action=Index}/{id?}");
// Frontend
//routes.MapRoute(name: "Standard", template: "{controller=Default}/{action=Index}/{id?}", defaults: new { }, constraints: new { controller = " " });
routes.MapRoute(name: "Default", template: "{culture=en}/{*url}", defaults: new { controller = "Default", action = "Index" });
}
);
}
示例15: Configure
public void Configure(IApplicationBuilder applicationBuilder)
{
RequestLocalizationOptions requestLocalizationOptions = new RequestLocalizationOptions();
requestLocalizationOptions.SupportedCultures = new List<CultureInfo>
{
new CultureInfo("en"),
new CultureInfo("uk")
};
requestLocalizationOptions.SupportedUICultures = new List<CultureInfo>
{
new CultureInfo("en"),
new CultureInfo("uk")
};
requestLocalizationOptions.RequestCultureProviders.Insert(0, new RouteValueRequestCultureProvider());
applicationBuilder.UseRequestLocalization(requestLocalizationOptions, new RequestCulture("en"));
}