20.5. Application Configuration Options

Virtually every custom application requires a place to store configuration information. Such configuration information may include Web service URLs, database connection data, as well as other application-specific configuration information. When building ASP.NET 2.0 applications, this configuration data can be stored in a custom database table or in configuration files, the most common being the web.config file. How should configuration data be handled in a custom application incorporated into or based on the SharePoint framework? Developers have a few options.

The configuration data can still remain in the web.config file, but this approach should be used with great care. Keep in mind that all sites (as well as site collections) in the Web application will have access to these settings, which might not be desirable for things such as database connection strings and login credentials. Another option is to store the configuration in a custom database or a special SharePoint list. The list can be secured quite easily to keep users from viewing the information, yet the application can use elevated privileges via the SPSecurity.RunWithElevatedPrivledges() method to retrieve values from the list. Refer to Chapter 15, "Authentication and Authorization," for more information on the SPSecurity.RunWithElevatedPrivledges() method.

There are two other options unique to SharePoint that ASP.NET 2.0 does not provide. One, many SharePoint objects contain ...

Get Professional SharePoint® 2007 Web Content Management Development: Building Publishing Sites with Office SharePoint Server 2007 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.