Solved

Webconfig + webservice + vb.net

Posted on 2007-11-14
2
442 Views
Last Modified: 2008-02-01
I have a basic question. I am in the process of cleaning up some code. I have a directory path stored in my webconfig file of a web service.
<add key="FilePath" value="c:\\projects\data\spider\" />

Dim FilePath as string
 FilePath=   System.Configuration.ConfigurationManager.AppSettings("FilePath")
It works fine .

In my web service I have a few methods which use this file path. In stead of calling this
Dim FilePath as string
 FilePath=   System.Configuration.ConfigurationManager.AppSettings("FilePath")
 in each and every method can I not set this up as when I start my service instead of always reading it from the webconfig file.
Where would I place this code of line such that all methods can access it? Is it even doable in a webservice.
Just curious!!
0
Comment
Question by:YRKS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
surajguptha earned 250 total points
ID: 20285615
The reason we have the AppSettings is because we dont have to put the app setting value in 10 different places. Instead we put it in the config file and call it with some name. That by itself is a simplification.

If you want it to be made even simpler.
You can write a class that would read the configuration file. In the get property you can add this code

But again if it was me i would just leave it as Configmanager :)
0
 
LVL 15

Assisted Solution

by:Solar_Flare
Solar_Flare earned 250 total points
ID: 20285636
YRKS,

the web.config file is loaded into memory when the application starts, so in fact it will not be hitting the disk every time you ask for the filepath.

if you really wanted to, you could put it in a static/shared object and use that object everywhere in your code but since it's not hitting the disk that probably isn't necessary.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question