473,499 Members | 1,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

to read Web.Config Section

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
2 7686
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
1426
by: vasu devan via DotNetMonster.com | last post by:
Hi, I am two config section with same config section handler like follow. <section name="Myformatters" type="MyFramework.Configuration.FileHandlers.MyConfigFileHandler, MyFramework"/> <section...
0
1824
by: Søren Lund | last post by:
Hello, I have implemented a custom config section handler by implementing the IConfigurationSectionHandler interface. I have registered this handler in web.config and everything works fine ......
0
1583
by: Shaun Ram | last post by:
Hi, I have this constraint. A help would be greatly appreciated. I have this Config file. <?xml version="1.0" encoding="utf-8" ?> <configuration> <configsections> <sectionGroup...
3
15949
by: Brett Romero | last post by:
I'd like to use some of the techniques discussed here for reading a config file in .NET 2.0: http://msdn.microsoft.com/msdnmag/issues/06/06/ConfigureThis/default.aspx Here's my app.config...
10
9416
by: Ryan | last post by:
I've created a custom configuration section that inherits (naturally) from System.Configuration.ConfigurationSection. The configuration section is working 99% fine, however I keep coming across a...
5
10322
by: alf | last post by:
Hi folks, I'm trying to read a web.config section using RoleManagerSection settings = (RoleManagerSection)System.Configuration.ConfigurationManager.GetSection("system.web/roleManager"); and I...
0
1854
by: =?Utf-8?B?SWFu?= | last post by:
Hi, I'm using VS 2005 SP1 with Web Deployment Project download v8.0.51103, according to the Add/Remove programs applet. I've got a file based web service project with an associated web...
3
2255
by: =?Utf-8?B?RHVrZSAoQU4yNDcp?= | last post by:
I've added a web deployment project and want to use the config section replacement but I'm obviously not understanding something. I have set up an alternate appSettings file,...
3
9108
by: sreemathy2000 | last post by:
My requirement is to read a store the value of values in the custome section of app.config. in the form load i need to read the custom section and populate the values in the combobox. section can...
0
7130
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7007
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7220
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4918
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4599
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3098
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1427
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
664
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
295
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.