Sharepoint features, custom aspx pages at various site levels

↘锁芯ラ 提交于 2020-01-06 08:16:30

问题


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.


回答1:


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.




回答2:


"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: Hidden Features of ASP.NET) or something similar.




回答3:


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.



来源:https://stackoverflow.com/questions/926607/sharepoint-features-custom-aspx-pages-at-various-site-levels

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!