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

where am i being called from? (web.config)

P: n/a
hello,

how do i check from my c# class if it is being called from a asp.net
application or a windows application?

i have some code that reads from the web.config file for webapps, but i want
to default the values to something else if there is no web.config (ie:
windows).

any ideas? thanks.
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
First, a desktop application can also have a config file that looks the same
as a web.config file, so simply the lack of a web.config does not indicate
that it is not a website. (Your application normally does not care where
the config settings came from -- app.config or web.config -- as long as it
has the same structure.)

You might try checking the HttpContext.Current property. If it is null,
then it is probably not a website.
"suzy" <su**@spam.com> wrote in message
news:Bl*****************@doctor.cableinet.net...
hello,

how do i check from my c# class if it is being called from a asp.net
application or a windows application?

i have some code that reads from the web.config file for webapps, but i want to default the values to something else if there is no web.config (ie:
windows).

any ideas? thanks.

Nov 18 '05 #2

P: n/a
"suzy" <su**@spam.com> wrote in message
news:Bl*****************@doctor.cableinet.net...
hello,

how do i check from my c# class if it is being called from a asp.net
application or a windows application?

i have some code that reads from the web.config file for webapps, but i want to default the values to something else if there is no web.config (ie:
windows).

any ideas? thanks.


Instead of reading from web.config explicitly, why not use
System.Configuration.ConfigurationSettings.AppSett ings? It will return
settings from whichever config file is appropriate.
--
John Saunders
John.Saunders at SurfControl.com

Nov 18 '05 #3

P: n/a
thanks guys. why didn't i think of that!!! :)
"Peter Rilling" <pe***@nospam.rilling.net> wrote in message
news:ex**************@tk2msftngp13.phx.gbl...
First, a desktop application can also have a config file that looks the same as a web.config file, so simply the lack of a web.config does not indicate
that it is not a website. (Your application normally does not care where
the config settings came from -- app.config or web.config -- as long as it
has the same structure.)

You might try checking the HttpContext.Current property. If it is null,
then it is probably not a website.
"suzy" <su**@spam.com> wrote in message
news:Bl*****************@doctor.cableinet.net...
hello,

how do i check from my c# class if it is being called from a asp.net
application or a windows application?

i have some code that reads from the web.config file for webapps, but i

want
to default the values to something else if there is no web.config (ie:
windows).

any ideas? thanks.


Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.