473,625 Members | 3,251 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.Collecti ons.Specialized .NameValueColle ction
test = CType
(System.Configu ration.Configur ationSettings.G etConfig("appSe ttings"),
System.Collecti ons.Specialized .NameValueColle ction)
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>

<globalizatio n requestEncoding ="iso-8859-1"
responseEncodin g="iso-8859-1"
culture="fr-FR" uiCulture="fr-FR" />
Dim testAs System.Collecti ons.Specialized .NameValueColle ction

test= CType
(System.Configu ration.Configur ationSettings.G etConfig("syste m.web/globalization") ,
System.Collecti ons.Specialized .NameValueColle ction)
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 7695
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******** ******@TK2MSFTN GP10.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.Collecti ons.Specialized .NameValueColle ction
test = CType
(System.Configu ration.Configur ationSettings.G etConfig("appSe ttings"),
System.Collecti ons.Specialized .NameValueColle ction)
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>

<globalizatio n requestEncoding ="iso-8859-1"
responseEncodin g="iso-8859-1"
culture="fr-FR" uiCulture="fr-FR" />
Dim testAs System.Collecti ons.Specialized .NameValueColle ction

test= CType
(System.Configu ration.Configur ationSettings.G etConfig("syste m.web/globalization") ,
System.Collecti ons.Specialized .NameValueColle ction)
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 = "/yourVirtualAppl icationPath"
Dim config As System.Configur ation.Configura tion = WebConfiguratio nManager.OpenWe bConfiguration( configPath)
Dim configSection As System.Web.Conf iguration.Globa lizationSection = CType(config.Ge tSection("syste m.web/globalization") , _
System.Web.Conf iguration.Globa lizationSection )
lblMessage.Text = "The web.config's file path is : " & config.FilePath
lblMessage2.Tex t = "The configuration section's name is : " & configSection.S ectionInformati on.Name
lblMessage3.Tex t = "The configured culture is : " & configSection.C ulture
lblMessage4.Tex t = "The configured uiCulture is : " & configSection.u iCulture
lblMessage5.Tex t = "The configured requestEncoding is : " & configSection.R equestEncoding. ToString()
lblMessage6.Tex t = "The configured responseEncodin g is : " & configSection.R esponseEncoding .ToString()
lblMessage7.Tex t = "The configured fileEncoding is : " & configSection.F ileEncoding.ToS tring()
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******** ******@TK2MSFTN GP10.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.Collecti ons.Specialized .NameValueColle ction
test = CType
(System.Configu ration.Configur ationSettings.G etConfig("appSe ttings"),
System.Collecti ons.Specialized .NameValueColle ction)
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>

<globalizatio n requestEncoding ="iso-8859-1"
responseEncodin g="iso-8859-1"
culture="fr-FR" uiCulture="fr-FR" />


Dim testAs System.Collecti ons.Specialized .NameValueColle ction

test= CType
(System.Configu ration.Configur ationSettings.G etConfig("syste m.web/globalization") ,
System.Collecti ons.Specialized .NameValueColle ction)
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
1439
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 name="Myserviceproxies" type=MyFramework.Configuration.FileHandlers.MyConfigFileHandler, MyFramework"/>
0
1836
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 ... for a while. At random points in time my section handler stops working and throws the exception: Configuration Error Description: An error occurred during the processing of a configuration
0
1594
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 name="mainsection"> <section name="ConnectionString" type="System.NamevaluesectionHandler,System" /> </sectiongroup>
3
15961
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 content: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections>
10
9449
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 ConfigurationErrorException whenever I do the following: 1. Modify and save the section in code using the System.Configuration.Configuration.Save(). 2. Refresh teh section using ConfigurationManager.RefreshSection 3. Encrypt the section,...
5
10333
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 get the following error on the page: Security Exception Description: The application attempted to perform an operation not allowed
0
1860
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 deployment project. I want to build my release version of the wdp with debug info so I can run NUnit on the output and doing that causes the wdp build to set <compilation debug="true"/in the web.config file. I've setup a replace config section...
3
2276
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, test.appSettings.config, and when I build the appSettings are correctly overridden, but I also end up with a copy of test.appSettings.config in my web site. If I have config sections for several environments they all get copied. How do I stop the copy? I wondered...
3
9125
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 be like <links> <add key="key1" value="any value"> <add key="key2" value="any value"> <add key="key3" value="any value"> </links>
0
8256
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8497
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7184
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4089
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4193
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2621
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 we have to send another system
2
1500
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.