Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2005

Tip: Looking for answers? Try searching our database.

Getting path of running codebehind ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
wl - 21 Jul 2005 22:46 GMT
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
Guillermo González A. - 21 Jul 2005 23:35 GMT
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
Brock Allen - 22 Jul 2005 01:57 GMT
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.

-Brock
DevelopMentor
http://staff.develop.com/ballen

> Hi,
>
[quoted text clipped - 22 lines]
>
> Wim

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.