问题描述
我正在使用资源文件切换在mvc5中构建的Web应用程序中的语言
I am using resource files to switch languages in my web application which is build in mvc5
在索引文件中,它读取我设置的文化值.
In index files its reading the culture value which i set.
我正在从layout.cshtml调用设置区域性方法,并使用以下代码调用其值.
I am calling the set culture method from layout.cshtml and calling its value with the following code.
@{
Layout = "~/Views/Shared/_Layout.cshtml";
if (!Request["dropdown"].IsEmpty())
{
Culture = UICulture = Request["dropdown"];
}
}
在索引页面中,语言已正确加载,但是从那里进入下一页时,它将加载默认语言德语,但资源仅从英语资源文件中读取.
in index page the language is loading correctly but when from there when i go to the next page its loading the default language German but the resources reading from English resource file only.
请帮助我这个..任何人
Please help me on this..anybody
推荐答案
在web.config
中,我在内部注释了以下行,对我来说很好用.
In web.config
I commented the following line inside and it worked fine for me.
<configuration>
<system.web>
<globalization culture="en-US" uiCulture="en-US" /> <!-- this only -->
</system.web>
</configuration>
这篇关于如何在MVC5中将文化设置为全局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!