[SOLVED] How to check if localhost


Is there a way in c# to check if the app is running on localhost (as opposed to a production server)?

I am writing a mass mailing program that needs to use a certain mail queue is it’s running on localhost.

if (Localhost)
Queue = QueueLocal;
Queue = QueueProduction;


Use a value in the application configuration file that will tell you what environment you are on.

Since you are using asp.net, you can utilize config file transforms to ensure the setting is correct for each of your environments.

Answered By – Oded

Answer Checked By – Willingham (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *