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
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