I am creating a site template in Sharepoint. I also have some custom .aspx page, that I want to deploy in Layouts\myDirectory. Using my site template I will create a Web (SPWeb) that should use the custom pages and reference them by an url of the form http://site/MyWeb/MyCustomPage.aspx. How do I integrate the pages in my custom template?
2 Answers
Pages stored in the Layouts folder are Application Pages and should always only be referenced through the _layouts virtual directory
If you want to reference the page as http://site/MyWeb/MyCustomPage.aspx then it should be a Site Page
A site page can be put inside a feature or directly inside a Site Definition (even thought I recommend that you only use the Site Definition to activate features). The way you provision the page is throught the Module & File elements see MSDN

- 3,767
- 17
- 19
-
These Site Pages, do they have to be web part pages or they can be simple asp.net pages with code-behind and user controls? – kjv Jul 22 '09 at 14:09
-
They can be both, just as long as the DLL is available to SHarePoint, either in the BIN folder or the GAC. – Colin Jul 22 '09 at 17:06
-
Think of the "pages" as files, as Per says they are provisioned through a module in the element.xml file in the feature (+1) – Johan Leino Jul 22 '09 at 18:51
A site template can only contain the contents of a single site/web. So you can't deploy files to the layouts folder using this technique.
However you can use site templates in combination with a solution package that copies your files. There is an example here. Deployment of the solution package will deploy your custom .aspx pages once. From then on they will be accessible to sites created by your site template.

- 59,219
- 41
- 137
- 210
-
My problem is not with copying the aspx file to the layouts directory. What I don't understand is how to reference them in the elements.xml file for the pages feature that will be used by the site template. – kjv Jul 22 '09 at 11:44