How to find out by a dll that it is using by a web application or window application

A

anilkumarup

Problem: I have to develop a component(dll) in C# for user management
section. the component will serve to any type of apllication like web
or window. Now the problem is in defining connection string (sql
server). If dll will be able to find out that it is calling by a web
application then the connection string can be picked from WEB.CONFIG
and in case of window application from somewhere else. Can any one
please help me for this
 
O

Oenone

If dll will be able to find out that it is calling by a web
application then the connection string can be picked from WEB.CONFIG
and in case of window application from somewhere else. Can any one
please help me for this

There are probably lots of ways to do this; here's one that I think should
work (this is VB code, you'll have to C#-ify it)

\\\
'Do we have an HttpContext?
If System.Web.HttpContext.Current Is Nothing Then
'We are running in a WinForms application
Else
'We are running in a web application
End If
///

HTH,
 

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

Top