As others have said, this is what the appSettings section of your web.config for
<configuration> <appSettings> <add key="isInTestMode" value="true"/> </appSettings> ... </configuration>
Accessed via WebConfigurationManager
bool isInTestMode = Boolean.Parse(WebConfigurationManager.AppSettings["isInTestMode"]);
However
If you are interested in not sending emails during testing, you can use web.config to configure .NET to upload emails to a local directory rather than sending them to a mail server.
<system.net> <mailSettings> <smtp deliveryMethod="SpecifiedPickupDirectory"> <specifiedPickupDirectory pickupDirectoryLocation="C:\MailDump\" /> <network host="localhost"/> </smtp> </mailSettings> ... </system.net>
This will work if your code does not override the default SMTP mail server settings.
source share