共用方式為


Determining Where to Build a Custom Application

Applies to: SharePoint Foundation 2010

You may want to create custom .aspx pages or Web applications and store them in a location that is accessible from all Web sites in your Microsoft SharePoint Foundation 2010 deployment. However, you may also want to create Web applications that contain custom code for central administrators to work with the global settings of a deployment.

Location for Custom ASPX Pages and Web Applications

You can build and store custom .aspx pages and Web applications in the following directory, which supports the _layouts virtual directory:

%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\LAYOUTS

Pages in this directory are accessible from all Web sites in the SharePoint Foundation deployment by using a URL in the following form:

https://Server/[sites/][Site]/[SubSite]/[.../]_layouts/File_Name.aspx

Location for Custom Code that Works with Global Settings

When you write custom code that only involves the Microsoft.SharePoint.Administration namespace and works with global settings in a SharePoint Foundation deployment, it is recommended that you create your Web application on the administrative port. Build and store .aspx pages and Web applications for the administrative port in the following directory:

%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\ADMIN

Pages in the \ADMIN directory are accessible by using a URL in the following form:

http://Server:Port_#/_admin/File_Name.aspx

For information about how to create a Web application in Microsoft Visual Studio 2010 that runs in the context of SharePoint Foundation, see Using Visual Studio for SharePoint Development.

Console applications can be created anywhere on the front-end Web server. For information about how to create a console application that runs in the context of SharePoint Foundation, see How to: Create a Console Application.

See Also

Concepts

Getting References to Sites, Web Applications, and Other Key Objects

Describing Forms of URL Strings

Using Visual Studio for SharePoint Development

Working with List Objects and Collections

Other Resources

Basic Object Model Tasks in SharePoint 2010