473,327 Members | 2,025 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,327 software developers and data experts.

adding custom setting into web.config, how??

ASP.NET 2.0

I'm wondering how to add a custom setting into web.config. From this website
I'm doing a http request to another website, and I would like to have the
webaddress of this other website stored as a value in web.config. So just in
case the webaddress is wrong I wouldn't need to recompile it later... So
where in web.config should such a custom setting be placed?

Lets say the custom section is like this:
<test>www.test.com/index.asp<test>

How can I access this <testvalue using configurationmanager?? or is it
correct to use configurationmanager to access the value??

Jeff
Apr 26 '07 #1
3 7878
Jeff,
does this work for you?

use appSettings in web.config like:

<appSettings>
<add key="urlTest" value="www.test.com/index.asp" />
</appSettings>

then you can read this value by doing:
Dim urlTest As String =
System.Web.Configuration.WebConfigurationManager.A ppSettings("urlTest")

you can add Imports System.Web.Configuration.WebConfigurationManager to your
souce file and use just
Dim urlTest As String = AppSettings("urlTest")

Bruno
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uu**************@TK2MSFTNGP04.phx.gbl...
ASP.NET 2.0

I'm wondering how to add a custom setting into web.config. From this
website I'm doing a http request to another website, and I would like to
have the webaddress of this other website stored as a value in web.config.
So just in case the webaddress is wrong I wouldn't need to recompile it
later... So where in web.config should such a custom setting be placed?

Lets say the custom section is like this:
<test>www.test.com/index.asp<test>

How can I access this <testvalue using configurationmanager?? or is it
correct to use configurationmanager to access the value??

Jeff

Apr 26 '07 #2
You can use the appSettings section :

<appSettings>
<add key="link1" value="http://www.test.com/index.asp"/>
</appSettings>

To get the setting :

<script language="vb" runat="server">
Sub Page_Load()
Dim mylink1 as String = (ConfigurationSettings.AppSettings("link1"))
' do something with the link1 string variable, which now holds the link you want.
End Sub
</script>

If you want to use the ConfigurationManager, use :

Dim mylink1 as String = ConfigurationManager.AppSettings.Get("link1")

Either one will do...


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Jeff" <it************@hotmail.com.NOSPAMwrote in message
news:uu**************@TK2MSFTNGP04.phx.gbl...
ASP.NET 2.0

I'm wondering how to add a custom setting into web.config. From this website I'm doing a http
request to another website, and I would like to have the webaddress of this other website stored
as a value in web.config. So just in case the webaddress is wrong I wouldn't need to recompile it
later... So where in web.config should such a custom setting be placed?

Lets say the custom section is like this:
<test>www.test.com/index.asp<test>

How can I access this <testvalue using configurationmanager?? or is it correct to use
configurationmanager to access the value??

Jeff

Apr 26 '07 #3
On 26 Apr, 23:05, "Juan T. Llibre" <nomailrepl...@nowhere.comwrote:
To get the setting :

<script language="vb" runat="server">
Sub Page_Load()
Dim mylink1 as String = (ConfigurationSettings.AppSettings("link1"))
' do something with the link1 string variable, which now holds the link you want.
End Sub
</script>
This method is documented as being obsolete in ASP.NET v 2

Is it a good idea to perpetuate it for new projects?

Apr 26 '07 #4

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

Similar topics

2
by: Paul Dunstone | last post by:
Hi group I am trying to add a custom attribute to all .NET elements such as textboxes, labels, datagrids etc. I want to add an attribute called 'key'. I already have the code working for the...
0
by: Guy Brom | last post by:
Hello, I'm trying to duplicate this "task" (of adding custom controls from webservice) to VS.net toolbox: http://www.asp.net/webmatrix/tour/section1/addcustomcontrol.aspx How can I do it? ...
2
by: Mark Friedman | last post by:
I've seen lots of documentation on how to create and read custom configuration settings but I'm interested in reading a standard setting (i.e. the loginUrl attribute of the authentication/forms...
1
by: Diffident | last post by:
Hello All, I have created my own custom configuration file. I would like to know about API available to read that config file. Since config file is nothing but an XML file, I could definitetly...
1
by: asnowfall | last post by:
I am creating MailMessage out of already existing email message. My existing message has few custom properties. I wan to add them to System.Net.Mail.MailMessage How to add custom properties? ...
0
by: nicolasl | last post by:
Hello, I have built a custom roleManager Provider that I have turned into a dll so I can share it accross multiple applications. When I try to add it to a web.config file I get the following...
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
0
by: nelis | last post by:
Anyone ever ran into the issue of adding custom properties to a user? Here's a code snippet i wrote: DirectoryEntry newUser = deContainer.Children.Add("CN=" + username, "User");...
0
by: Nithi Gurusamy | last post by:
I have generated a Web-Service-Proxy (Add Web Reference) within VS. This proxy class is based on WebServicesClientProtocol of WSE 3.0. I want to add some custom HTTP Headers to the envelop before...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.