In A Web App?

B

bradwiseathome

I have a DLL that is sometimes used in a ASP.NET 2.0 web app, sometimes
it is used by a console app (unit test). How can I determine if the
current instance (it's not a static class) is definitely running inside
ASP.NET?
 
C

Cowboy \(Gregory A. Beamer\)

Why? Does it work completely differently in the unit test class than in the
web application? If so, why? Because you want to focus on the unit only?
Okay, are you using mock objects and injecting them? If not, why not?

The point I am getting to is there is no reason a class should operate
differently under test than live, except perhaps having mocks for
dependencies to avoid actually calling a database, fvor example.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
 
S

sloan

Try this:


if ( null == System.Web.HttpContext.Current )
//Non Web Environment
{

}
else
{

}
 
B

bradwiseathome

I have a custom configuration file that the class opens, and it is
relative to the place where the assembly/type/class loaded. If I'm in
an ASP.NET app, I need to know where it is vs a console app (in a unit
test) where it'll be likely somewhere else.

Thanks.
 

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