Determine if ASP.NET website project is running in development environment

Is it possible to determine if asp.net web project is running in the development environment (visual studio).   In a few of the projects i have some of the asp.net mail functions settings differ depending if they are running in the IDE or production.
Mike_StevensAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
You could use conditional compilation. You could wrap the mail-related code in an #if Not DEBUG directive, and when you're running locally the mail code will not exist (so far as the compiler is concerned; otherwise, the mail code will run as expected.

e.g.

Sub SomeMethod()
#If Not DEBUG
    Dim client As New SmtpClient()
...
#End If
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
käµfm³d 👽Commented:
P.S.

When you switch your settings to RELEASE mode, the DEBUG flag no longer exists (provided you haven't fiddled with the project's properteis), so that makes the check true, and the mail code will be compiled at that time.
0
Russ SuterCommented:
You could also check the URL. What I do is modify my web.config to reference a second .config file for appsettings. I then can compile and publish the website without publishing the appsettings.config file which makes deployment much easier. On the rare occasion that I need to add new settings I can do that manually. It's much more common for me to need to publish an update without changing the appsettings.config file.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.