By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

Can I use multiple web.config ?

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.