473,320 Members | 1,982 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Reading from Web.config

TPS
What is the best way to read values from the web.config file.

I know how to read from the appSettings section, I want to read from other
sections like those listed below.

Thanks,
TPS
<customErrors mode="Off" defaultRedirect="/Pages/customerror.aspx"/>

<authentication mode="Forms">

<forms

slidingExpiration="true"

loginUrl="/pages/login.aspx"

name="dusacookie"

timeout="60"

path="/">

</forms>

</authentication>

<trace

enabled="false"

requestLimit="10"

pageOutput="true"

traceMode="SortByTime"

localOnly="true"

/>

Nov 18 '05 #1
3 2439
You can create your own sections via configurationHandlers, you can read up
on this at:
http://openmymind.net/Configuration/index.html

However, I think what you are saying is you want to read the application
values from the web.config. A lot of those are read into objects you can
access. For example you can type Page.Trace.TraceMode to get the mode
specified in web.config

You can use Session.SessionMode/TimeOut

You can also get some from Context.IsCustomErrorEnabled

As you can see, they are read into a veriaty of objects...and I'm not sure
all the information is available. You might need to simply read it as an
XML document and parse it....

Not sure why you'd want this information anyways..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"TPS" <tp*@tps.com> wrote in message
news:uz**************@tk2msftngp13.phx.gbl...
What is the best way to read values from the web.config file.

I know how to read from the appSettings section, I want to read from other
sections like those listed below.

Thanks,
TPS
<customErrors mode="Off" defaultRedirect="/Pages/customerror.aspx"/>

<authentication mode="Forms">

<forms

slidingExpiration="true"

loginUrl="/pages/login.aspx"

name="dusacookie"

timeout="60"

path="/">

</forms>

</authentication>

<trace

enabled="false"

requestLimit="10"

pageOutput="true"

traceMode="SortByTime"

localOnly="true"

/>

Nov 18 '05 #2
Thanks for Karl's good suggestions.

Hi TPS,

As for reading the settings in the web.conrfig I think Karl's suggestions
are quite reasonable. Also, there may be some scenarios that we can't read
web.config via those means, for example , in design-time .., then I think
we can just load the web.config as a normal xmlDocument and use the DOM
collection to retrieve any elements we want. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
TPS
Thanks for both of your suggestions

TPS
"Steven Cheng[MSFT]" <v-******@online.microsoft.com> wrote in message
news:a8**************@cpmsftngxa06.phx.gbl...
Thanks for Karl's good suggestions.

Hi TPS,

As for reading the settings in the web.conrfig I think Karl's suggestions
are quite reasonable. Also, there may be some scenarios that we can't read
web.config via those means, for example , in design-time .., then I think
we can just load the web.config as a normal xmlDocument and use the DOM
collection to retrieve any elements we want. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sami | last post by:
Hello, I have this problem that I need your help with : I am reading a config file that contain the following : 2004 update
3
by: spacekid | last post by:
Hi there I am exposing a c# assembly as a COM component (regasm /codebase) and calling it from classic asp. When I try to call the ConfigurationSettings.AppSettings function in the c# assembly,...
2
by: news.microsoft.com | last post by:
Hi After conducting a several searches, I wasn't sure where to post this question. So my apologiesbefore hand for double posting this and possibly posting to the wrong forum(s). Okay, I have...
1
by: comic_rage | last post by:
Hi, I am trying to read from my application config file and keep getting null. Here is my config file My application is called SampleApp.exe
10
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...
2
by: marek zegarek | last post by:
Hello! On my server I have Sharepoint portal server as default web site I create there a web application folder with form.aspx file. When I'm trying to run aspx, i get an error. Page is trying...
5
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...
9
by: Milsnips | last post by:
Hi all. i'm tryng to implement the Rewrite.NET url rewritining functionality into a test project i've created, however i am hitting a problem at this line (direct from the web example): ...
1
by: M Irfan | last post by:
Hello all, Recently I have started working in .NET 2.0. I am developing a web service application that references a DLL component written in C# 2.0. The component has its own config file which...
1
by: vijayarl | last post by:
Hi Everyone, i have the written this logic : basically a file operation open (CONFIGFILE, "$config_file") or die; while (<CONFIGFILE>) { chomp;
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.