Custom administration pages can be used in Central Administration for a variety of purposes. One such scenario can be creating a page in CA for storing database connection string and using it in timer jobs. In this post we will create an administration page and use persisted objects to store data in SharePoint configuration database.
Create an empty SharePoint 2010 project with the following structure:
Copy this markup to the SampleCAAdminpage.aspx page.
Change the public key token in Page directive line to your value.
Use the following code in connection.cs file:
Use following code in SampleCAAdminPage.cs class:
Use follwoing xml in Elements file of CustomAction element:
Ensure that the feature has Farm level scope:
Finally deploy the solution and go to CA and click on Application management. Notice the section for configuring XYZ project.
Enter and save database connection string and list name in the page.
Inside the timer job or any SharePoint code the above saved values can be retrieved as follows:
Connection con = Connection.Local;