Home > Net >  ASP.NET Core deployment to CentOS, language resources can only load the default language resource fi
ASP.NET Core deployment to CentOS, language resources can only load the default language resource fi

Time:02-03

Version: the.net Core 2.1
Do multilingual web site at ASP.NET in the Core, whether by IIS deployment on Windows, or through dotnet launch, language switching works, may demand loading for different language pack, but released to Cent OS 7.5, language resources to load the default language pack only.
My concrete realization way is as follows:
This added to the routing request language
 
Routes. The MapRoute (
Name: "UploadMvc,"
The template, "UploadMvc/{action}/{id? },
"Defaults: new {controller="UploadMvc," action="UpdataFile"}
);

Routes. The MapRoute (
Name: "default",
Template: "{lang}/{controller}/{action}/{id? },
"Defaults: new {lang="useful - CN", the controller="Home", action="Index"},
Constraints: new {lang="useful - cn | | ko en - us | DE - DE - kr | es - es | ja - jp"}
);

Get into the current in the Controller to use the language, and save into the codebehind (categories.aspx.cs).
 
Public override void OnActionExecuting (ActionExecutingContext context)
{
Var routeData=https://bbs.csdn.net/topics/context.RouteData;
Var lang="useful - cn";
If (routeData!=null & amp; & RouteData Values!=null)
{
Var langObj=routeData. Values [" lang "];
If (langObj!=null)
{
Lang=langObj. ToString (). ToLower ();
}
}
Language=lang;
The codebehind (categories.aspx.cs) [" language "]=lang;
}

Set the current area, if links to useful - cn region is set to current Chinese
 
Thread. The CurrentThread. CurrentUICulture=new CultureInfo (codebehind (categories.aspx.cs) (" language ") as string);
Thread. The CurrentThread. CurrentCulture=CultureInfo. CreateSpecificCulture (codebehind (categories.aspx.cs) (" language ") as string);

Language resources package

Then the program used in
 
Language. Index_IMPLANT

To obtain the response of language Settings, Index_IMPLANT is the name of the resource file.

This way again under Windows deployment everything is normal, but under CentOS deployment, can only load the default Language, also is the Language of the Language, not according to the different Language of setting area load.

Tested: the URL of the incoming language can obtain, normal CurrentUICulture and CurrentCulture Settings, also works area is correct, is can't find the language packs.

After the release of directory




For advice.

CodePudding user response:

May not install the corresponding system character library,
  • Related