MOSS/SharePoint: use custom aspx pages only for some SharePoint sites

Source: Internet
Author: User
We often encounter the following requirements:

We can create An ASPX page, deploy it to the 12 \ template \ layouts directory, and install it using feature (if there is a DLL, copy to the \ bin directory of the corresponding SharePoint site ).
There is no problem with this, but the _ layouts directory is accessible to all sites. I need to achieve this: http: // mossdemo/onesite/customapp/custompage1.aspx
The current implementation is:
Http: // mossdemo/onesite/_ layouts/custompage1.apsx
And, more seriously, if I try this:
Http: // mossdemo/anothersite/_ layouts/custompage1.aspx
It also works. But in fact I only install this feature on onesite.

Solution:

Assume that our feature directory is called mmapp, and the complete path is c: \ Program Files \ common files \ microsoft shared \ Web Server Extensions \ 12 \ template \ Features \ customapp

The following content is provided:
2 files
Feature. xml
Elements. xml
One folder named custompages. Used to store our aspx pages. There are two page files:
Custompage1.aspx
Custompage2.aspx

We can organize the content of feature. XML as follows: <? XML version = "1.0" encoding = "UTF-8" ?>
< Feature ID = "{AAA4124D-2A89-43df-8427-F820D7B20CC9 }" Title = "Fileuploaddemo" Xmlns = "Http://schemas.microsoft.com/sharepoint" Hidden = "False" Scope = "Web" Version = "1.0.0.0" Description = "Loads a file into SharePoint site" Creator = "" >
< Elementmanifests >
< Elementmanifest Location = "Elements. xml" />
< Elementfile Location = "Custompages \ custompage1.aspx" />
< Elementfile Location = "Custompages \ custompage2.aspx" />
</ Elementmanifests >
</ Feature >

The content of elements. XML is as follows: <? XML version = "1.0" encoding = "UTF-8" ?>
< Elements Xmlns = "Http://schemas.microsoft.com/sharepoint" >
< Module Path = "Custompages" Name = "Custompages" >
< File Path = "Custompage1.aspx" Name = "" Type = "Ghostable" URL = "Custompages/custompage1.aspx" />
< File Path = "Custompage2.aspx" Name = "" Type = "Ghostable" URL = "Custompages/custompage2.aspx" />
</ Module >
</ Elements >

For testing, the content of custompage1.aspx is simple, but the title of spweb is displayed. The content is as follows: < % @ Assembly Name = "Microsoft. Sharepoint. applicationpages, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" % >

< % @ Page Language = "C #"  
Masterpagefile = "~ Masterurl/Default. Master" % >

< % @ Import Namespace = "Microsoft. Sharepoint. applicationpages" % >
< % @ Register Tagprefix = "SharePoint" Namespace = "Microsoft. Sharepoint. webcontrols"
Assembly = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" % >
< % @ Register Tagprefix = "Utilities" Namespace = "Microsoft. Sharepoint. Utilities" Assembly = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" % >
< % @ Import Namespace = "Microsoft. SharePoint" % >
< % @ Register Tagprefix = "SharePoint" Namespace = "Microsoft. Sharepoint. webcontrols"
Assembly = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" % >
< % @ Register Tagprefix = "Utilities" Namespace = "Microsoft. Sharepoint. Utilities" Assembly = "Microsoft. Sharepoint, version = 12.0.0.0, culture = neutral, publickeytoken = 71e9bce111e9429c" % >
< % @ Import Namespace = "Microsoft. SharePoint" % >

< Script Runat = "Server" >

Protected void page_load (Object sender, eventargs E)
{
This. lbtest. Text = spcontext. Current. Web. title;
}
</ Script >

< ASP: Content ID = "Content1" Contentplaceholderid = "Placeholderpagetitle" Runat = "Server" >
< SharePoint: encodedliteral ID = "Encodedliteral1" Runat = "Server" Text = "Custom page 1"
Encodemethod = 'Htmlencoding'   />
</ ASP: Content >
< ASP: Content ID = "Content2" Contentplaceholderid = "Placeholderpagetitleintitlearea"
Runat = "Server" >
< SharePoint: encodedliteral ID = "Encodedliteral" Runat = "Server" Text = "Custom content"
Encodemethod = 'Htmlencoding'   />
</ ASP: Content >
< ASP: Content ID = "Content3" Contentplaceholderid = "Placeholderadditionalpagehead" Runat = "Server" >
< Meta Name = "Robots" Content = "Noindex"   />
< Meta Name = "Effecpointerror" Content = ""   />
</ ASP: Content >
< ASP: Content ID = "Content4" Contentplaceholderid = "Placeholdermain" Runat = "Server" >
< Table Width = "100%" Border = "0" Class = "MS-titleareaframe" Cellpadding = "0" >
< Tr >
< TD Valign = "TOP" Width = "100%" Style = "Padding-top: 10px" Class = "MS-descriptiontext" >
< Span Class = "MS-descriptiontext" >
< ASP: Label ID = "Lbtest" Runat = "Server" Text = "" > </ ASP: Label >
</ Span >
</ TD >
</ Tr >
</ Table >

</ ASP: Content >

After everything is ready, install feature:Stsadm-O installfeature-name customapp

Then go to a Sharepoint site (such as http: // mossdemo/onesite) and activate the website function (called fileuploaddemo ).
 
Now, you can access our ASPX page in the following ways:
Http: // mossdemo/onesite/custompages/custompage1.aspx
Send a chart

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.