Why does my MVC application cache this option?

I have an email listening application that processes incoming emails, depending on the "Bucket" (or Queue) that the emails are in. One parameter for each bucket is AutoRespond. If AutoRespond is correct, I send a confirmation email to the sender.

However, when I change the AutoRespond parameter, it does not seem to take effect. I am familiar with installing OutputCache on the controller, but this logic is below from my cs email listening service file.

if (myObject.Bucket.AutoRespond)
{
    SendEmailConfirmation(someArgs);
}

This if statement is still evaluated as True, although I can see that it is set to False in the database. If I restart my email listening service, everything will be fine and the if statement will evaluate correctly. Any ideas?

+3
source share
2 answers

Probably the problem is that the settings are read from the database only when the application starts ... then, probably, they are stored in a static variable or in the application state dictionary. If so, you can solve this problem by writing an administrative page that, after changing the settings, will force the settings to be reloaded from the database.

+1
source

web.config, , ( , , )

web.config:

<appSettings>
    <add key="AutoRespond" value="true" />
</appSettings>

# :

bool autoRespond = false;
bool.TryParse(System.Configuration.ConfigurationManager.AppSettings["AutoRespond"], out autoRespond);
+1

All Articles