looking for local / remote directory path solution

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello everyone,

I'm looking for a "directory path" solution that will allows me to test my
app locally and then test on remote web server without having to update my
web.config file each time I modify the file. In other words I'm storing the
paths (for centralizing purposes) as custom <appSettings> in the web.config.

expample (for local testing):
<add key="imagePath" value="http://localhost/app_folder/10_media/images/" />

expample (for remote testing):
<add key="imagePath" value="http://www.domain.com/10_media/images/" />

Is there a way to have the app run the local path when testing locally and
vice versa without manually changing the web.config ?

Any thoughts/solutions will be appreciated!

Thanks,
Enrique
 
You could store the path in a registry key on each machine and read it into
an Application variable in global.asax on Application_Start.
 
Hello,

I had the same problem, but think that I have solved it in a simple and
ellegant way (at least it proved very useful for me):
Just defined a custom configuration library that handles reading of XML
configuration files. And the library supports 'include files' based on
some predefined criteria, such as machine name. In my applications it
simply loads master config file and config.<machinename>.xml include
file that contains machine-specific settings.
In web.config I store only relative path to my master config file, so I
can distribute the web.config without any modification to different
machines. I also distribute all config files (for all machines) together
with the app, so all installations contain the same files.
And that's all. My library has grown a bit and now supports quite a lot
of features besides configuration, but it is not open source yet - maybe
someday. I'm sure you can make something similar in a hour or two, so
probably you won't wait for me anyway.

Best regards,
Rafal Gwizdala
 
Back
Top