473,396 Members | 2,089 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Multiple web applications and web.config

I've developed an single sign on web application that we'd like to use with
all the applications we're developing. The application's connection string
is stored in web.config. I've gotten some basic functionality worked out and
I'm attempting to test it on another application, whose connections string to
another database is also stored in web.config. I make a reference in the
testing application to the authentication application dll, but when I run the
test, the authentication app uses the web.config file of the testing
application. Is there a way I can force it to use the web.config file in
it's own application?
Jul 21 '05 #1
3 2321
No, assemblies will read the config file that is "mapped" to the process
under which they are running. DLLs have no "app.config" or anything like
that; they use the one the framework loads for the host EXE.

In this case your library is running under the IIS process and that means
the framework will load the web.config that corresponds to the web
application.

You could of course read the XML using a relative path and normal DOM/XPath
methods, but System.Configuration would be out of the picture and you'd have
a host of different problems.

If you need centralized configuration settings you should save them to a
separate file under, say, \Documents And Settings\All Users\Application
Data\MyApp\... or use the HKLM\Software section of the registry.
--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Craig" <Cr***@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
I've developed an single sign on web application that we'd like to use with all the applications we're developing. The application's connection string is stored in web.config. I've gotten some basic functionality worked out and I'm attempting to test it on another application, whose connections string to another database is also stored in web.config. I make a reference in the
testing application to the authentication application dll, but when I run the test, the authentication app uses the web.config file of the testing
application. Is there a way I can force it to use the web.config file in
it's own application?

Jul 21 '05 #2
Alternatively you could try section groups in the config file and write your
own custom configuration section handler.

Your config sections would look something like this:

<sites>
<sites
... Global Site Settings
<siteSettings>
<clear/>
<add name="SiteName1"
property="Property1"
setting="Setting1"
... etc />
... More add statements per site
</siteSettings>
</site>
</site>

Then you would need to create a class that will load the configurations
settings and store them in say a hash table with the siteName as the key,
you can then retrieve these by a property call passing in the siteName to
get the correct settings.

You would also need an internal class that implements the
IConfigurationSectionHandler, which has one method Create, this would
instantiate your configuration class, load the values from the xml and then
return the instantiated object.

All sounds complicated but its quite straight forward, if you want some
sample code let me know.

Hope this helps
Regards
Neil

"Klaus H. Probst" <us*******@simulplex.net> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl... No, assemblies will read the config file that is "mapped" to the process
under which they are running. DLLs have no "app.config" or anything like
that; they use the one the framework loads for the host EXE.

In this case your library is running under the IIS process and that means
the framework will load the web.config that corresponds to the web
application.

You could of course read the XML using a relative path and normal
DOM/XPath
methods, but System.Configuration would be out of the picture and you'd
have
a host of different problems.

If you need centralized configuration settings you should save them to a
separate file under, say, \Documents And Settings\All Users\Application
Data\MyApp\... or use the HKLM\Software section of the registry.
--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Craig" <Cr***@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
I've developed an single sign on web application that we'd like to use

with
all the applications we're developing. The application's connection

string
is stored in web.config. I've gotten some basic functionality worked out

and
I'm attempting to test it on another application, whose connections
string

to
another database is also stored in web.config. I make a reference in the
testing application to the authentication application dll, but when I run

the
test, the authentication app uses the web.config file of the testing
application. Is there a way I can force it to use the web.config file in
it's own application?


Jul 21 '05 #3
I didn't really want to combine the config files because some of the
consuming applications will reside on different servers. I had already tried
writing a function to pull the SiteSettings into a hash table, but I still
ran into the following problem.
Project A references Project B,
Project B has a function GetSiteSettings that reads an XML file, mapped

using "AppDomain.CurrentDomain.BaseDirectory" + "web.config"
Calling GetSiteSettings from Project B gets me the file I want, in
project B dir.
Calling GetSiteSettings from Project A gets me the file from the project
A dir.

What I'm trying to do is have GetSiteSettings() get the web.config file from
the project B directory regardless of which project calls it. I'm thinking I
may just have to expose these functions as a webmethods.

"Neil Stevens" wrote:
Alternatively you could try section groups in the config file and write your
own custom configuration section handler.

Your config sections would look something like this:

<sites>
<sites
... Global Site Settings
>

<siteSettings>
<clear/>
<add name="SiteName1"
property="Property1"
setting="Setting1"
... etc />
... More add statements per site
</siteSettings>
</site>
</site>

Then you would need to create a class that will load the configurations
settings and store them in say a hash table with the siteName as the key,
you can then retrieve these by a property call passing in the siteName to
get the correct settings.

You would also need an internal class that implements the
IConfigurationSectionHandler, which has one method Create, this would
instantiate your configuration class, load the values from the xml and then
return the instantiated object.

All sounds complicated but its quite straight forward, if you want some
sample code let me know.

Hope this helps
Regards
Neil

"Klaus H. Probst" <us*******@simulplex.net> wrote in message
news:uR**************@TK2MSFTNGP11.phx.gbl...
No, assemblies will read the config file that is "mapped" to the process
under which they are running. DLLs have no "app.config" or anything like
that; they use the one the framework loads for the host EXE.

In this case your library is running under the IIS process and that means
the framework will load the web.config that corresponds to the web
application.

You could of course read the XML using a relative path and normal
DOM/XPath
methods, but System.Configuration would be out of the picture and you'd
have
a host of different problems.

If you need centralized configuration settings you should save them to a
separate file under, say, \Documents And Settings\All Users\Application
Data\MyApp\... or use the HKLM\Software section of the registry.
--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Craig" <Cr***@discussions.microsoft.com> wrote in message
news:13**********************************@microsof t.com...
I've developed an single sign on web application that we'd like to use

with
all the applications we're developing. The application's connection

string
is stored in web.config. I've gotten some basic functionality worked out

and
I'm attempting to test it on another application, whose connections
string

to
another database is also stored in web.config. I make a reference in the
testing application to the authentication application dll, but when I run

the
test, the authentication app uses the web.config file of the testing
application. Is there a way I can force it to use the web.config file in
it's own application?



Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
6
by: Andrew Connell | last post by:
I have an app where I want virtually everything password protected/secure except for a single directory. That directory handles some custom authentication and contains my login form, but also some...
2
by: James X. Li | last post by:
Is there a way to implement multiple login forms for ASP.NET applications? With our application we want to implement simple login form for normal resources (downloadable files), but more rigorous...
5
by: BPearson | last post by:
Hello I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to...
2
by: Sean | last post by:
I have an ASP.NET web application that needs to be rolled out to a number of clients. The functionality is the same in all applications, but each client has its own database. At the moment, I...
6
by: Ludvig | last post by:
I have various domains using the same application/assembly They differ in contents and design, based on a "site id", and get its information from an SQL server. Now I have to deploy the...
3
by: Craig | last post by:
I've developed an single sign on web application that we'd like to use with all the applications we're developing. The application's connection string is stored in web.config. I've gotten some...
1
by: herbert | last post by:
In VS.2005 a Windows Service can have an app.config file. A class library can also have an app.config file. Now if my Windows Services uses three class libraries, each of it coming with its own...
3
by: | last post by:
I'm seeking (probably basic) guidance on the right way to split a large site that's supposed to represent one domain(mydomain.org) into many small VS.NET projects, and how to avoid issues with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.