VAB config file changes not affecting validation

Topics: Enterprise Library Core, General discussion, Validation Application Block
Aug 15, 2007 at 6:15 PM

I have created a configuration source section of my web.config file. The code is below:

<enterpriseLibrary.ConfigurationSource selectedSource="validation">
<add name="validation" type="....FileConfigurationSource, ....Common, Version=3.1......"
filePath="validation.config" />

Inside validation.config I have:
<section name="validation" type="....ValidationSettings, ...Validation, Version="/>
My validation rules here

When I make changes to validation.config and upload those changes to the server, my changes don't take affect right away. I had the validation code in the web.config file originally, but needed to move it out to its own config file. When it was in the web.config file, changes were seen immediatly.

Is there a way to make my changes to the validation.config file effective as soon as I upload it to the server (the same way that the web.config file was working)? How would I go about doing this?

Aug 15, 2007 at 6:50 PM
When you changed the web.config the application was restarted, so it was a new instance picking up the fresh changes.

The validation application block will cache the validators, so if you change the configuration after it has been read by the block the changes will unfortunately not be picked up until you invoke the static method ValidationFactory.ResetCaches() from within the application or restart it.

Aug 15, 2007 at 7:57 PM

I tried to call validationFactory.ResetCaches from a button on my page, but the validation rules don't get updated on the server.

I would prefer not to restart the application every time I change the validation rules

Any idea why the ResetCaches isn't working?

Aug 15, 2007 at 8:23 PM

I think this might be an issue of saving the configuration and/or uploading the configuration. Sometimes it works fine, other times it doesn't. I will play around with this more and if I get more information, I will post it here.

Thanks for your help
Aug 16, 2007 at 12:45 PM

Configuration should be refreshed after a change in the configuration file's timestamp is detected. It can take up to 20 seconds to detect the change, and the timestamp must be properly updated.

Can this explain the behavior you see?

Aug 20, 2007 at 9:08 PM

Yes, that explains the behavior