c# - 多个资源文件与单个资源文件

标签 c# performance asp.net-mvc-4 resources

这个问题是关于性能的

我正在开发 MVC4,我想支持多语言 View 。

我正在为每种语言使用一个资源文件,如下所示:

Multi.resx For English as default
Multi.ar.resx for Arabic 
Multi.fr.resx for Frensh

在指定文化之后,我在我的观点中这样做

@Multi.Name

但是,我设置了断点来检查 @Multi 的值,实际上它包含了我资源中的所有键。想象一下所有这些:P

我的问题是:如果我为每个 View 使用一个资源文件,它的性能会更好吗?或者即使我为每个 View 使用多个资源文件,当我运行我的应用程序时是否会加载所有资源?

我真的不擅长英语,如果你不明白我的问题,就让我澄清一下。

最佳答案

我知道这是旧线程,但我也在寻找答案。 单个(和巨大的资源)文件是否会影响性能?

经过研究,我发现了这个link我想与您分享(以防您仍在寻找)。

好吧,简短的回答是NO,它不会影响性能。但是,在大型团队中工作时可能会出现问题(每个程序员都需要修改相同资源文件)并且合并更改会很麻烦。

这是来自 MSDN 的指南:

Choosing Between Global and Local Resource Files

You can use any combination of global and local resource files in the Web application. Generally, you add resources to a global resource file when you want to share the resources between pages. Resources in global resource files are also strongly typed for when you want to access the files programmatically.

However, global resource files can become large, if you store all localized resources in them. Global resource files can also be more difficult to manage, if more than one developer is working on different pages but in a single resource file.

Local resource files make it easier to manage resources for a single ASP.NET Web page. But you cannot share resources between pages. Additionally, you might create lots of local resource files, if you have many pages that must be localized into many languages. If sites are large with many folders and languages, local resources can quickly expand the number of assemblies in the application domain.

When you make a change to a default resource file, either local or global, ASP.NET recompiles the resources and restarts the ASP.NET application. This can affect the overall performance of your site. If you add satellite resource files, it does not cause a recompilation of resources, but the ASP.NET application will restart.

我希望这可以帮助寻求相同答案的人。

干杯, 山姆

关于c# - 多个资源文件与单个资源文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19910926/

相关文章:

c# - 无法在运行时找到静态资源,即使设计师可以看到它

c# - 获取本地机器上安装的所有证书

performance - 访问控件值的最有效方法是什么?

c# - 在后台运行异步操作方法

jquery - MVC4 不显眼的验证不等待远程验证完成

c# - IE7/8 : PDF file won't download with HTTP GET

c# - 主窗口中的 float 窗口

java - 将多个线程与 RandomAccessFile 一起使用有助于提高性能吗?

performance - Prime sieve 导致(我要去)堆栈溢出

asp.net-mvc-4 - 如何输出Request.CreateResponse方法的json对象