How to determine if I am in a web or a windows application

J

Jean Paul Mertens

Hello to all,

I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is serving a
web or a windows application. Is there a neat way to detect this.

Greets

Jean.Paul
 
H

Herfried K. Wagner [MVP]

Jean Paul Mertens said:
I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is serving
a web or a windows application. Is there a neat way to detect this.

Check out 'System.Reflection.Assembly.GetEntryAssembly'.
 
G

Guest

Hello Jean Paul,

You could do it by figuring out the which program/assembly is calling the
exception handling library. Based on that you can differentiate whether
win/web app is calling .

If you don't have control over exception handling library, meaning if the
lib is blackbox to you, the only way to attack this scenario is to play with
generated exception message. Try adding more information to the exception
message of the exception object and call the exception handling library with
the exception.

Pls let me know whether this is useful to you and let me know whether you
need more information
 
E

Eliyahu Goldin

In most scenarios this will do:

/// <value>Indicates that the application is running in ASP.NET</summary>

public static bool IsWeb

{

get {return System.Web.HttpContext.Current != null;}

}
 
S

sloan

I agree with this one. (aka, Eliyahu's)

I use this one fairly often.

Keep in mind which namespace/assembly its in.


PS

You normally dont' need to post to 4 or more groups.




Eliyahu Goldin said:
In most scenarios this will do:

/// <value>Indicates that the application is running in ASP.NET</summary>

public static bool IsWeb

{

get {return System.Web.HttpContext.Current != null;}

}


--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]



Jean Paul Mertens said:
Hello to all,

I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is serving
a web or a windows application. Is there a neat way to detect this.

Greets

Jean.Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,076
Latest member
OrderKetoBeez

Latest Threads

Top