Getting path of running codebehind ?

W

wl

Hi,

For an asp.net application I would like to store the DB connectionstring to
be used in a configuration file.
I know I can use the web.config file for this (and know how to read from
it). However, because I have my asp.net application hosted all codebehind
DLL's need to be put into the same BIN directory.

Therefore I would like to store the db configuration string for each
application into it's own configuration file. This configuration file could
have the same name (and be in the same BIN directory) as the codebehind DLL,
but with another file extention (XML instead of DLL).

eg: \BIN directory
project1.dll
project1.xml
project2.dll
project2.xml


Does anyone know how I can do this:
1. getting the absolue path of the codebehind DLL
2. reading from this file ?

Thanks in advance,

Wim
 
?

=?iso-8859-1?Q?Guillermo_Gonz=E1lez_A.?=

Hi wl,

You can store each application in a separate folder and in this folder put a web.config file containing the respective connection string.

\bin\ <DLL's>

MyApp1\MyApp1 <files>
MyApp1\MyApp1 web.config

MyApp2\MyApp2 <files>
MyApp2\MyApp2 web.config

Guillermo G.

--------------------------------------------------------------------------------
Guillermo González Arroyave :: MCP ASP.Net C# :: DCE4

Hi,

For an asp.net application I would like to store the DB connectionstring to
be used in a configuration file.
I know I can use the web.config file for this (and know how to read from
it). However, because I have my asp.net application hosted all codebehind
DLL's need to be put into the same BIN directory.

Therefore I would like to store the db configuration string for each
application into it's own configuration file. This configuration file could
have the same name (and be in the same BIN directory) as the codebehind DLL,
but with another file extention (XML instead of DLL).

eg: \BIN directory
project1.dll
project1.xml
project2.dll
project2.xml


Does anyone know how I can do this:
1. getting the absolue path of the codebehind DLL
2. reading from this file ?

Thanks in advance,

Wim
 
B

Brock Allen

I'm not sure what you're looking for but:

AppDomain.CurrentDomain.BaseDirectory gets the AppBase of the application
which will be the parent directory of ~/bin in ASP.NET. You can also call
Assembly.GetExecutingAssembly().CodeBase to get the currently executing assembly's
location it was located by the assembly resolver.
 

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

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,821
Latest member
AleidaSchi

Latest Threads

Top