Reputation: 16031
Basically, the question in the title - how can I / is it possible to determine that Cassini is what's running my app versus IIS? Basically I want my code to know that it's debugging, so if I'm missing something easier here, please point it out.
Upvotes: 1
Views: 633
Reputation: 5451
return AppDomain.CurrentDomain
.GetAssemblies()
.Any(
a => a.FullName.StartsWith("WebDev.WebHost")
);
Upvotes: 6
Reputation: 38179
If your goal is solely to determine whether you are debugging (in which case the build configuration will probably be debug), you can use something like:
#if DEBUG
// Code compiled only if debug configuration selected (not release)
#endif
More info here
Upvotes: 2
Reputation: 16031
While I like a lot of the ideas here, I think I found a simple way to accomplish this.
System.Diagnostics.Debugger.IsAttached
This gives a boolean depending on whether there's a debugger attached to the executing code.
I still like the #if
code provided by vc 74, but this code serves my purpose better.
Upvotes: 0
Reputation: 63264
Analyze the HTTP response and see what is the Server field. That should tell the truth. IIS will tell it is IIS (with version number) by default.
Upvotes: 0
Reputation: 124
If I am understanding you correctly, you want to determine if you are in debug mode or not and perhaps apply some debugging logic?
In the past, I have accomplished what you are attempting to achieve using a key that I added in the web.config. When I am developing and debugging, I set the variable RunningFromVisualStudio=true and when I promote to production, I set it the variable to false.
Hope that helps.
Upvotes: 1
Reputation: 21971
The following suggest that your app is running under casini:
Upvotes: 1
Reputation: 74939
You can look at the port. Casini always runs on a random high port. IIS will usually be 80 or 443 unless you've configured it differently.
Upvotes: 2