Get Central Administration Webapplication
With this code you can get the central administration webapplication.
1: private static SPWebApplication GetCentralAdministrationWebApplication()
<span class=lnum> 2: </span>{
3: SPWebService cS = SPWebService.ContentService;
<span class=lnum> 4: </span> var service = cS.Farm.Services.GetValue<SPWebService>(<span class=str>"WSS_Administration"</span>);
5: SPWebApplicationCollection webApplications = service.WebApplications;
<span class=lnum> 6: </span> <span class=kwrd>foreach</span> (SPWebApplication webApplication <span class=kwrd>in</span> webApplications)
7: {
<span class=lnum> 8: </span> <span class=kwrd>return</span> webApplication;
9: }
<span class=lnum> 10: </span> <span class=kwrd>return</span> <span class=kwrd>null</span>;
11: }
If you have a better way, let me know 🙂
And here we go. A big Thank you goes to Axel Heer.
return SPAdministrationWebApplication.Local;