我们可以从web.config文件中获取属性吗? [英] Can we fetch attributes from web.config file?

查看:73
本文介绍了我们可以从web.config文件中获取属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从web.config文件中获取'Culture'和'uiCulture'值到我的代码隐藏文件。



该应用程序仍在接受我的系统文化,在某些情况下,即使我已经定义了'文化'和'uiculture'的价值观。



我尝试过:



我使用下面的代码来获取详细信息。





I need to fetch the 'Culture' and 'uiCulture' value from the web.config file to my code behind file.

The application is still taking my system culture,in some scenarios, even though I have defined the 'culture' and 'uiculture' values.

What I have tried:

I had used the below code to fetch the details.


Dim configSection As System.Web.Configuration.GlobalizationSection = CType(config.GetSection("system.web/globalization"), _
System.Web.Configuration.GlobalizationSection)





但在某些情况下,它会返回系统文化值。

请帮我解析一下。



我正在考虑直接将web.config属性分配给后面的代码,以便它会被覆盖。



请给我一个建议。



But in some scenarios it is returning the System culture value.
Please help me out in resolving the same.

I am thinking of directly assigning the web.config attributes to the code behind so that it will be overridden.

Please provide me a suggestion.

推荐答案

为什么你认为这个web.config中的文化会有所帮助吗?

您需要参考用户(客户端)文化,以及存储所有信息而不是访问随机的集中式文化对于所有用户来说,文化将会回归。



通常情况下,服务器软件会请求客户文化,以便它可以规范化用户输入(特别是日期)和数字)到一般的存储格式 - 可以是你喜欢的任何格式,但建议使用UTC日期时间值。然后,它在输出数据时将该常规存储格式转换为适当的客户端文化,而不必再担心输入格式。
Why do you think that fetching a culture from web.config would help at all?
You need to refer to the user (client) culture, and the "centralised" culture in which you store all information rather than accessing a "random" culture which will come back the same for all users.

Normally what happens is that the Server software requests the Client culture so it can "normalise" user input (particularly dates and numbers) to a general format for storage - which can be whatever you are comfortable with, but UTC DateTime values are recommended. It then converts that general storage format to the appropriate Client culture when it outputs data, and doesn't have to worry about the input format any more.


这篇关于我们可以从web.config文件中获取属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆