473,503 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 16 '05 #1
3 1896
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 16 '05 #2
"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 16 '05 #3
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 16 '05 #4

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

Similar topics

3
6548
by: Geoff Pennington | last post by:
It is really pathetic that I don't know this, but here it is. I have been writing ASP.Net apps for a while, and all configuration information, such as the database connection string, goes in a text...
2
3823
by: Martin | last post by:
Hi I am noticing some strange behaviour in some asp.net pages that I have put together and am hoping someone can explain to me what is happening. I have two domains hosted at oneandone.co.uk....
0
984
by: Tim Zych | last post by:
Does anybody know what's wrong with this authentication? I'm following the book ASP.Net Kick Start's advice.... 1) Create a new ASP.Net app 2) Create a web.config file in the root directory...
6
2565
by: Martin | last post by:
Hi, Since I went ASP.NET with my global.asa (making it a global.asax) the application events are called just fine as well as the Session_OnStart event but the Session_OnEnd event is not. What is...
7
2844
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
3
1178
by: suzy | last post by:
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...
3
2021
by: Ingo Lundberg | last post by:
So, I have a brand new PC with XP Professional SP2 and .Net 1.1 SP1 (no .Net 1.0). I also have VS.Net 2003. I create a new directory with Explorer and web share it. I create a new ASP.Net web...
4
1257
by: Nikolay Petrov | last post by:
I have an class library, which I shared with some of my apps. Some of them are Winfroms apps, others are ASP .NET. How could I check from a method in my library, is it called form an Winforms or...
6
2793
by: BookerW | last post by:
Ok interesting, on my local machine And i did not do a good job of keeping track of the exact order.... but on my local machine in which i have vis studio 2003 installed and IIS for win XP,...
0
7280
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7330
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...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.