R – How to provision a custom page without using the _layouts directory

mosssharepointsharepoint-2007

I need to provision a custom aspx page which does some work and then redirects to another page. Using a _layouts page, AKA an application page won't work since I only want this page accessible to one site collection.

I looked at using pattern #4 from blog post Application Development on MOSS 2007 and WSS V3. It feels pretty hacky, and it asks you to drop the DLL. Drop it into the bin of the site collection, and upload the file through SP Designer.

I'd rather have this page be a feature that gets included in my site definition or stapled to an existing site definition. I imagine I could use a feature receiver to deploy the files to the pages SP list. One of the comments on the blog post says as much:

Pardon my ignorance on this maybe I am
missing the point completely but
wouldnt it be easier to deploy your
custom pages by programmatically
adding them to the pages splist?

I basically, had a simple .aspx page
with a user control. I deployed it via
this method.

How can a custom page be provisioned without using a _layouts page?

I guess another option is to keep using a _layouts page, but make sure the referrer is correct.

Best Answer

Besides application pages, you also have the possibility to create site pages.

Site pages are in nature related to application pages, but they reside in a site not in _LAYOUTS.

The welcome page (default.aspx) is an example of such a page.

In the same way as with application pages, it is possible to do codebehind in these pages (check out AC's article on this subject, Using ASP.NET 2.0 Code Behind Files in SharePoint v3 Sites)

You can read this article regarding the subtle differences between application pages and site pages: SharePoint Application and Site Pages - Part 1 of 2

You deploy this custom page using a feature, where you specify the file as ghostable (look at the example in ACs article).