By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,572 Members | 946 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,572 IT Pros & Developers. It's quick & easy.

to read Web.Config Section

P: n/a
Hello,

Is that a way for reading section of the web.config by code ?
I m able to read the section <appSettings> like this :
<appSettings>
<add key="AppVer" value="Version 0.8 beta"/>
</appSettings>
Dim test As System.Collections.Specialized.NameValueCollection
test = CType
(System.Configuration.ConfigurationSettings.GetCon fig("appSettings"),
System.Collections.Specialized.NameValueCollection )
dim mytest as string = CType (test("AppVer"), String )
response.write(mytest)

And it's OK

But i can't with the section globalization

<system.web>

<globalization requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
culture="fr-FR" uiCulture="fr-FR" />
Dim testAs System.Collections.Specialized.NameValueCollection

test= CType
(System.Configuration.ConfigurationSettings.GetCon fig("system.web/globalization"),
System.Collections.Specialized.NameValueCollection )
dim mytest as string = CType (test("culture"), String )
'response.write(mytest)

it does not work.

How can i get information in globalization section ?

thanks
fabrice
Dec 1 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
You won't be able to use System.Config to help you, but you can load it like
a normal XML file and use xpaths or some other method.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"fabrice" <em******@test.com> wrote in message
news:OU**************@TK2MSFTNGP10.phx.gbl...
Hello,

Is that a way for reading section of the web.config by code ?
I m able to read the section <appSettings> like this :
<appSettings>
<add key="AppVer" value="Version 0.8 beta"/>
</appSettings>
Dim test As System.Collections.Specialized.NameValueCollection
test = CType
(System.Configuration.ConfigurationSettings.GetCon fig("appSettings"),
System.Collections.Specialized.NameValueCollection )
dim mytest as string = CType (test("AppVer"), String )
response.write(mytest)

And it's OK

But i can't with the section globalization

<system.web>

<globalization requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
culture="fr-FR" uiCulture="fr-FR" />
Dim testAs System.Collections.Specialized.NameValueCollection

test= CType
(System.Configuration.ConfigurationSettings.GetCon fig("system.web/globalization"),
System.Collections.Specialized.NameValueCollection )
dim mytest as string = CType (test("culture"), String )
'response.write(mytest)

it does not work.

How can i get information in globalization section ?

thanks
fabrice

Dec 1 '05 #2

P: n/a
In ASP.NET 2.0, it's fairly easy :

Dim configPath As String = "/yourVirtualApplicationPath"
Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(confi gPath)
Dim configSection As System.Web.Configuration.GlobalizationSection = CType(config.GetSection("system.web/globalization"), _
System.Web.Configuration.GlobalizationSection)
lblMessage.Text = "The web.config's file path is : " & config.FilePath
lblMessage2.Text = "The configuration section's name is : " & configSection.SectionInformation.Name
lblMessage3.Text = "The configured culture is : " & configSection.Culture
lblMessage4.Text = "The configured uiCulture is : " & configSection.uiCulture
lblMessage5.Text = "The configured requestEncoding is : " & configSection.RequestEncoding.ToString()
lblMessage6.Text = "The configured responseEncoding is : " & configSection.ResponseEncoding.ToString()
lblMessage7.Text = "The configured fileEncoding is : " & configSection.FileEncoding.ToString()
etc...

Juan T. Llibre
ASP.NET.FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================

"fabrice" <em******@test.com> wrote in message news:OU**************@TK2MSFTNGP10.phx.gbl...
Hello,

Is that a way for reading section of the web.config by code ?
I m able to read the section <appSettings> like this :


<appSettings>
<add key="AppVer" value="Version 0.8 beta"/>
</appSettings>


Dim test As System.Collections.Specialized.NameValueCollection
test = CType
(System.Configuration.ConfigurationSettings.GetCon fig("appSettings"),
System.Collections.Specialized.NameValueCollection )
dim mytest as string = CType (test("AppVer"), String )
response.write(mytest)

And it's OK

But i can't with the section globalization

<system.web>

<globalization requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
culture="fr-FR" uiCulture="fr-FR" />


Dim testAs System.Collections.Specialized.NameValueCollection

test= CType
(System.Configuration.ConfigurationSettings.GetCon fig("system.web/globalization"),
System.Collections.Specialized.NameValueCollection )
dim mytest as string = CType (test("culture"), String )
'response.write(mytest)

it does not work.

How can i get information in globalization section ?

thanks
fabrice

Dec 1 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.