{"id":3,"date":"2009-12-04T10:39:46","date_gmt":"2009-12-04T09:39:46","guid":{"rendered":"http:\/\/www.juergenholz.de\/?p=3"},"modified":"2017-12-27T09:15:39","modified_gmt":"2017-12-27T08:15:39","slug":"timer-job-zugriff-auf-die-web-config","status":"publish","type":"post","link":"https:\/\/www.juergenholz.de\/en\/timer-job-zugriff-auf-die-web-config\/","title":{"rendered":"Timer Job needs access to the web.config"},"content":{"rendered":"<div style=\"color: #555555; text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-weight: 400; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; background-color: #ffffff; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;\"><span id=\"noHighlight_0.32340072604205505\">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?<\/span><\/div>\n<div style=\"color: #555555; text-transform: none; text-indent: 0px; letter-spacing: normal; font-family: 'Segoe UI', Tahoma, Helvetica, sans-serif; font-size: 13px; font-style: normal; font-weight: 400; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; background-color: #ffffff; font-variant-ligatures: normal; font-variant-caps: normal; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;\"><span id=\"noHighlight_0.840554141392625\">The solution is relatively simple, using the following namespaces<br \/>\n<\/span><span id=\"noHighlight_0.9295117103919517\">Using System. Web. Configuration;<br \/>\n<\/span><span id=\"noHighlight_0.10784958372864661\">using System. Configuration;<br \/>\n<\/span><span id=\"noHighlight_0.1449429126643016\">I get access to our relevant objects.<br \/>\n<\/span><span id=\"noHighlight_0.07371279001622866\">Configuration config = WebConfigurationManager. OpenWebConfiguration (&#8220;\/&#8221;, this. WebApplication.Name);<br \/>\n<\/span><span id=\"noHighlight_0.4145526667552475\">string testapp = config. appsettings. Settings [&#8220;&lt; &gt;&#8221;]. Value;<\/p>\n<p><\/span><span id=\"noHighlight_0.24801311302709594\">Et voila, we can get the relevant settings in the Execute method of the job.<\/span><span id=\"noHighlight_0.506538480901745\">Have fun<\/span><\/div>\n<div class=\"juerg-endepost\" style=\"margin-left: auto;margin-right: auto;text-align: center;\" id=\"juerg-2775891113\"><div class=\"juerg-adlabel\">Werbung<\/div><script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-4708705370860748\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:inline-block;width:728px;height:90px;\" \ndata-ad-client=\"ca-pub-4708705370860748\" \ndata-ad-slot=\"4810788593\"><\/ins> \n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[8,9],"translation":{"provider":"WPGlobus","version":"3.0.0","language":"en","enabled_languages":["de","en"],"languages":{"de":{"title":true,"content":true,"excerpt":false},"en":{"title":true,"content":true,"excerpt":false}}},"_links":{"self":[{"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/posts\/3"}],"collection":[{"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/comments?post=3"}],"version-history":[{"count":3,"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/posts\/3\/revisions"}],"predecessor-version":[{"id":239,"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/posts\/3\/revisions\/239"}],"wp:attachment":[{"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/media?parent=3"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/categories?post=3"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.juergenholz.de\/en\/wp-json\/wp\/v2\/tags?post=3"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}