A TimerJob with the scope WebApplication can be activated by any WebApp. How do I get the name of the WebApplication or its web. config to access relevant settings such as appsettings or connectionstrings?
The solution is relatively simple, using the following namespaces
Using System. Web. Configuration;
using System. Configuration;
I get access to our relevant objects.
Configuration config = WebConfigurationManager. OpenWebConfiguration (“/”, this. WebApplication.Name);
string testapp = config. appsettings. Settings [“< >”]. Value;

Et voila, we can get the relevant settings in the Execute method of the job.Have fun

Werbung

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed