views:

896

answers:

3

I've asked a similar sort of question here but what to be more specific.

I want to be able to deploy a solution and activate a feature that provisions various custom aspx pages to different site levels within my web site.

So my first custom aspx page would be at the root: http://example.org/custompage1.aspx

And then another custom aspx page would appear at a deeper level: http://example.org/subsite1/custompage2.aspx

I've got my solution scoped to the "web" level. If I activate the feature at the sub site level I can access the custom aspx page that should appear at this deeper level, but, I can also access the other page that should only appear at the root of the web site e.g. http://example.org/subsite1/custompage1.aspx

Which is wrong, wrong, wrong!

I tried to scope the feature to “site” but this only seemed to provision the root custom aspx page, not the page that should appear at the deeper level of the web site.

+3  A: 

"Custom aspx" pages are known in SharePoint as "Application" pages, and they are deployed in the _layouts directory (usually C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS). All pages inside the Layouts directory are available from every site in the web application.

If you know in advance which page goes with which site then you could put code in each custom page that checks to see if it's being accessed from an "invalid" site, and if so, throw a custom 404 error (see here: http://stackoverflow.com/questions/54929/hidden-features-of-asp-net/55229#55229) or something similar.

Chloraphil
after looking at your other question, if you want certain application pages to only be accessible to site administrators, check out the RequireSiteAdministrator property: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.layoutspagebase.requiresiteadministrator.aspx
Chloraphil
I think we've mixed the terminology here, I've used the term custom aspx pages to mean web pages I've created in visual studio that have code behind files and can be accessed by a 'normal' web site user. In this context I don't mean application pages.
Rob
Yep, application pages. See here: http://msdn.microsoft.com/en-us/library/bb418732.aspx
Chloraphil
A: 

Clorphil nailed the answer. I would only add that you can use SPContext.Current.Web within your page to determine which web site you are in when called.

Kirk Liemohn
+1  A: 

Anything you do in the feature xml will only apply to the site on which the feature is activated. If you want to do something across multiple sites based on relative urls, you will need to set up a feature receiver and use custom code to deploy files/features to the other sites.

The easiest approach is probably to create a seperate web scoped feature within your solution and have the site scoped feature receiver activate it on subsites.

Tom Clarkson
Cool, thanks Tom, I think your're on the right track, seems a bit long winded though, but then again it is sharepoint.
Rob