Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6732915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:42:25+00:00 2026-05-26T10:42:25+00:00

Is it possible, pragmatically, to tell whether an ASP.NET web app is running in

  • 0

Is it possible, pragmatically, to tell whether an ASP.NET web app is running in the Cassini web server in Visual Studio, or in IIS?

Background and reason for asking:

In quite a few of our apps, we bypass the normal login settings in a login page by checking the machine name, or by checking to see if the Client IP is localhost. (127.0.0.1 or :::1) so that we can test and have the app behave differently while debugging on our development PCs.

The Machine name approach is OK, but the wee need to change the code when we get a new Dev PC. I realize this isn’t too often, but it feels sloppy. Also, with several developers working on it, we have to list all of our machines in the “if” statement.

As for the “localhost” approach, I don’t like it. It seems to add another attack surface. I worry about someone getting onto one of the web servers and running it locally and seeing stuff.

So I wonder if there’s a way from code to detect that the website is running from Visual Studio with the Cassini web server.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:42:26+00:00Added an answer on May 26, 2026 at 10:42 am

    When running under IIS the SERVER_SOFTWARE property of the ServerVariables collection reports something like Microsoft-IIS/7.5.

    Unfortunately this appears to be blank when running under Cassini.

    I don’t know if this helps you as it seems the opposite way round to the desired behaviour if you are concerned about security.

    from comments:

    Check the System.Diagnostics.Process.GetCurrentProcess().ProcessName For Cassini it’s “WebDev.WebServer40” and for IIS it’s “w3wp”

    string processName= System.Diagnostics.Process.GetCurrentProcess().ProcessName;
    if (processName == "WebDev.WebServer40")
    {
       // testing
       // Insert code that you want to happen if this is running in Visual Studio
    }
    

    If this is running in IIS, the pName variable will be “w3wp. In Visual Studio on a .NET 4.0 app, it’s “WebDev.WebServer40”. (I haven’t checked but I assume it would be WebDev.WebServer20 for ASP.NET 2.0)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How can I properly handle 404 in ASP.NET MVC? I've made the
Possible Duplicate: Saving changes after table edit in SQL Server Management Studio I need
Possible Duplicate: .NET - What’s the best way to implement a catch all exceptions
Possible Duplicate: How do you send email from a Java app using Gmail? How
as shown here its possible to get the default IIS mime types from HKEY_Classes_Root.
Possible Duplicate: Can a Bash script tell what directory it's stored in? Is there
I've been working on a CMS based in ASP.NET MVC2 using a poco based
Possible Duplicate: .NET Enumeration allows comma in the last field public enum SubPackageBackupModes {
Possible Duplicate: How costly is .NET reflection? The elegant solution to a problem I
Possible Duplicate: Why not use tables for layout in HTML? Under what conditions should

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.