Checking the source of method call
-
I have developed a component for my web application using C#. Now I want to reuse same component for a console app also. Now I need to identify whether the request is coming from console application or web app..other than that the component is independent of any session or source. I do not want to pass hint through a var.. any other ideas???
Keep DotNetting!! GeekFromIndia
-
I have developed a component for my web application using C#. Now I want to reuse same component for a console app also. Now I need to identify whether the request is coming from console application or web app..other than that the component is independent of any session or source. I do not want to pass hint through a var.. any other ideas???
Keep DotNetting!! GeekFromIndia
you can check to if the HttpContext is null.If HttpContext is not null then its an ASP.NET web application:
if (HttpContext.Current != null)
{
//We are in a web app, use a request scope
}