472,805 Members | 950 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Can I use multiple web.config ?

Hi,

Is it possible to specify the location of a web.config file in an
ASP.NET application?

I have one ASP.NET application which is to be hosted on 2 web sites in the
same web server. I want to configure the 2nd web site as virtual directory
so that the 2 web sites are pointing to the same application. However, there
are different configuration settings for the 2 web sites, so that accessing
these 2 sites' same ASP.NET application will have different outcome.
Thanks and Regards,
George
Nov 19 '05 #1
5 10951
No, you cant use multiple web.config for one application. If you tell us
what information you are getting it from web.config file. Then we can
provide with different options for doing that.
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"George" <ge**********@asia.morningstar.com> wrote in message
news:#9**************@TK2MSFTNGP09.phx.gbl...
Hi,

Is it possible to specify the location of a web.config file in an
ASP.NET application?

I have one ASP.NET application which is to be hosted on 2 web sites in the
same web server. I want to configure the 2nd web site as virtual directory
so that the 2 web sites are pointing to the same application. However, there are different configuration settings for the 2 web sites, so that accessing these 2 sites' same ASP.NET application will have different outcome.
Thanks and Regards,
George

Nov 19 '05 #2
Thanks for your reply.

Suppose I have 2 websites "abc.com" and "cde.com", both pointing to the same
physical path on the server.
I have a config section in web.config, for example, defines the greeting
message in the web site.

If a client connect to "abc.com", my aspx page will display a message
"Welcome to ABC World".
If a client connect to "cde.com", my aspx page (the same page) will display
the message "Welcome to My second World", for example. (These messages will
not have any relationship with the domain name so we won't simply get the
domain name)

So I just want to define this greeting message in the web.config file and
have it displayed according to different web sites.
Actually there's much more to config and many different pages, so we will
not consider programatically write the logics in the code behinds.

Thanks.

George

"Saravana" <sa******@sct.co.in> wrote in message
news:nj*****************@news.cpqcorp.net...
No, you cant use multiple web.config for one application. If you tell us
what information you are getting it from web.config file. Then we can
provide with different options for doing that.
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"George" <ge**********@asia.morningstar.com> wrote in message
news:#9**************@TK2MSFTNGP09.phx.gbl...
Hi,

Is it possible to specify the location of a web.config file in an
ASP.NET application?

I have one ASP.NET application which is to be hosted on 2 web sites in the same web server. I want to configure the 2nd web site as virtual directory so that the 2 web sites are pointing to the same application. However,

there
are different configuration settings for the 2 web sites, so that

accessing
these 2 sites' same ASP.NET application will have different outcome.
Thanks and Regards,
George


Nov 19 '05 #3
My suggestion is to create your own .config file. For example
<yoursitename>.config and place it in your web directory. For each site you
can have one config file, you write your own logic to read the data from
config file. So site1 reads its data from site1.config file and site2 reads
its data from site2.config. You can place generice data in web.config file.

This might not be a best solution. If you need more information, then get
back to me.
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"George" <ge**********@asia.morningstar.com> wrote in message
news:OW**************@TK2MSFTNGP10.phx.gbl...
Thanks for your reply.

Suppose I have 2 websites "abc.com" and "cde.com", both pointing to the same physical path on the server.
I have a config section in web.config, for example, defines the greeting
message in the web site.

If a client connect to "abc.com", my aspx page will display a message
"Welcome to ABC World".
If a client connect to "cde.com", my aspx page (the same page) will display the message "Welcome to My second World", for example. (These messages will not have any relationship with the domain name so we won't simply get the
domain name)

So I just want to define this greeting message in the web.config file and
have it displayed according to different web sites.
Actually there's much more to config and many different pages, so we will
not consider programatically write the logics in the code behinds.

Thanks.

George

"Saravana" <sa******@sct.co.in> wrote in message
news:nj*****************@news.cpqcorp.net...
No, you cant use multiple web.config for one application. If you tell us
what information you are getting it from web.config file. Then we can
provide with different options for doing that.
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"George" <ge**********@asia.morningstar.com> wrote in message
news:#9**************@TK2MSFTNGP09.phx.gbl...
Hi,

Is it possible to specify the location of a web.config file in an
ASP.NET application?

I have one ASP.NET application which is to be hosted on 2 web sites in

the same web server. I want to configure the 2nd web site as virtual directory so that the 2 web sites are pointing to the same application. However,

there
are different configuration settings for the 2 web sites, so that

accessing
these 2 sites' same ASP.NET application will have different outcome.
Thanks and Regards,
George



Nov 19 '05 #4
Actually my problem is how to have different configuration settings if the
application is of one physical folder but just pointed by 2 web sites or
virtual directory.

Here are more details:

1st Website "Default Web Site"
- domain name "abc.com"
- home directory: "C:\MyWebSite"
- web.config: "C:\MyWebSite\web.config"
2nd Website "CDE"
- domain name "cde.com"
- home directory: "C:\MyWebSite"
- web.config: "C:\MyWebSite\web.config"

All the pages under the ASP.NET application uses the same web.config which
is placed at the web root folder. so if I have custom settings for each of
the web site, how can I do it?

Thanks

Best Regards,
George

"Saravana" <sa******@sct.co.in> wrote in message
news:nj*****************@news.cpqcorp.net...
No, you cant use multiple web.config for one application. If you tell us
what information you are getting it from web.config file. Then we can
provide with different options for doing that.
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"George" <ge**********@asia.morningstar.com> wrote in message
news:#9**************@TK2MSFTNGP09.phx.gbl...
Hi,

Is it possible to specify the location of a web.config file in an
ASP.NET application?

I have one ASP.NET application which is to be hosted on 2 web sites in the same web server. I want to configure the 2nd web site as virtual directory so that the 2 web sites are pointing to the same application. However,

there
are different configuration settings for the 2 web sites, so that

accessing
these 2 sites' same ASP.NET application will have different outcome.
Thanks and Regards,
George


Nov 19 '05 #5
Follow Saravana's suggestion about making your config files. It's not
terribly difficult to do (see StreamReader) and makes this a lot
better. As to how to detect the host (abc.com or cde.com), use
Request.Url.Host.

Essentially:

protected class Settings {
public string Name;
};

private Settings mySettings = new Settings();

private void Page_Load(object sender, System.EventArgs e)
{
string fileName;

if (Request.Url.Host == "abc.com")
fileName = "abc.config";
else
fileName = "cde.config";

// Read file and assign Settings as appropriate
}

While not a complete solution, it should be enough to get you started.

James
George wrote:
Actually my problem is how to have different configuration settings
if the application is of one physical folder but just pointed by 2
web sites or virtual directory.

Here are more details:

1st Website "Default Web Site"
- domain name "abc.com"
- home directory: "C:\MyWebSite"
- web.config: "C:\MyWebSite\web.config"
2nd Website "CDE"
- domain name "cde.com"
- home directory: "C:\MyWebSite"
- web.config: "C:\MyWebSite\web.config"

All the pages under the ASP.NET application uses the same web.config
which is placed at the web root folder. so if I have custom settings
for each of the web site, how can I do it?

Thanks

Best Regards,
George

"Saravana" <sa******@sct.co.in> wrote in message
news:nj*****************@news.cpqcorp.net...
No, you cant use multiple web.config for one application. If you
tell us what information you are getting it from web.config file.
Then we can provide with different options for doing that.
--
Saravana
http://dotnetjunkies.com/WebLog/saravana/
www.ExtremeExperts.com
"George" <ge**********@asia.morningstar.com> wrote in message
news:#9**************@TK2MSFTNGP09.phx.gbl...
Hi,

Is it possible to specify the location of a web.config file
in an ASP.NET application?

I have one ASP.NET application which is to be hosted on 2 web
sites in the same web server. I want to configure the 2nd web site as virtual directory so that the 2 web sites are pointing to the same application.
However,

there
are different configuration settings for the 2 web sites, so that

accessing
these 2 sites' same ASP.NET application will have different
outcome.
Thanks and Regards,
George



Nov 19 '05 #6

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

Similar topics

1
by: Vlad | last post by:
Is there any way to install multiple instances of the same windows service designed with VS.NET 2003? I tried copying the binaries into a separate folder and then copying registry entries for the...
0
by: raj | last post by:
when using multiple configuration files, we can use file attribute to use common config file, if i am using configSections in my config file how do i use multiple configuration files. please how...
22
by: Daniel Billingsley | last post by:
Ok, I wanted to ask this separate from nospam's ridiculous thread in hopes it could get some honest attention. VB6 had a some simple and fast mechanisms for retrieving values from basic text...
4
by: Shrinivas | last post by:
Hi, Let us say my web.config is keep growing and I want to break the data logically and still use web.config methods to retrieve the data. e.g. <?xml version="1.0" encoding="utf-8" ?>...
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...
0
by: mlafarlett | last post by:
Geez...seems like i've compared every friggin character...works n this programA but not n programB. I have a config file with multiple sections and when trying to read each section, it works great...
2
by: Sam | last post by:
Hi All, I have a solution which consists of multiple projects and each of these projects has their own app.config file. The problem is that all of my projects in the solution pull keys from the...
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: =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post by:
Hi, Is there a way in .NET 1.1 to have to have one VB app use two different ..config files. We have one program which is used for two different customers; each customer will have his own config...
2
by: Fresno Bob | last post by:
I quite like to store variables in the web.config file. However it can make the web.config messy and make deployment fiddly. Is there any way of have multiple web.config files - one with the major...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.