Is there any way to create an environment variable through IIS?

0

I have an application running in local IIS and also in production. In this application, I have a feature where, when an error occurs, an email is sent. The problem is that I do not want this to happen when I'm in a development environment.

I thought of determining some environment variable to do this in IIS (however I want this variable to be specific to that application).

Is there any way to set environment variables specific to an application running in IIS?

    
asked by anonymous 25.01.2018 / 13:31

1 answer

2

You can define in your web.config , in the compilation tag, the debug attribute:

In the development environment:

<configuration>  
    ...  
    <system.web>  
        <compilation  
            debug="true"  
            ...  
        >  
        ...  
        </compilation>  
    </system.web>  
</configuration>  

In the production environment:

<configuration>  
    ...  
    <system.web>  
        <compilation  
            debug="false"  
            ...  
        >  
        ...  
        </compilation>  
    </system.web>  
</configuration>  

Inside the application, you check whether you are in debug mode, and you are sending:

if (!HttpContext.Current.IsDebuggingEnabled) 
{
    //envia o email
}
else
{
    //não envia email ou envia para outro endereço
}

References:

link link

    
25.01.2018 / 14:07