newbie: web.config for a webservice!

J

Jeff

Hi all!

IDE: Visual Studio 2003 .NET
OS: XP Pro

I'm experimenting with c# and created a webservice. I want to put
configuration settings into the web.config file so that the webservice gets
more flexible...

Below are 3 questions:

Question 1:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="KeyName" value="KeyValue" />
</appSettings>

I have no problem accessing the value of KeyName with
"ConfigurationSettings.AppSettings["KeyName"];". But that doesn't mean it's
correct

My question is: Is my use of <appSettings> inside web.config correct?? I ask
because I thought <appSetting> only was an application setting, and not for
a webservice


Question 2:
KeyName/KeyValue is just for testing. But does .NET have any standards for
the name of a key?? for example for the database name???... or can the
developer use any name he wants to???


Question 3:
Is it correct to put database settings inside <appSetting>, or prefer .NET
to have the database settings elsewhere inside the web.config???

Jeff
 
M

Mohamoss

Hi jeff
here you are some inline answers
My question is: Is my use of <appSettings> inside web.config correct?? I ask
because I thought <appSetting> only was an application setting, and not for
a webservice
-- there is not problem with that . app setting can be used with windows
application , web applications and webservices .
your web.config file is not accessible to outside user even if they
provided the url


KeyName/KeyValue is just for testing. But does .NET have any standards for
the name of a key?? for example for the database name???... or can the
developer use any name he wants to???

--Mostly is use the object name ( full name ). For exaple if you are saving
the text property of a button named button1 in a windos application class
named myapp . keyname would be myapp.button1.text


Is it correct to put database settings inside <appSetting>, or prefer .NET
to have the database settings elsewhere inside the web.config???

-- check out this link
http://www.codeproject.com/aspnet/secure_connectionstrings.asp
hope this answers your questions
Mohamed Mahfouz
MEA Developer Support Center
ITworx on behalf of Microsoft EMEA GTSC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top