Partager via


How to: Customize the Mobile Home Page through Redirection

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

By default, Windows SharePoint Services 3.0 uses a bi-level redirection mechanism for Web sites. The mobile home page has a short URL with an "m" folder appended to the end of the regular URL (for example, http(s)://Server/sites/Site/m/) that redirects the request to the mobile default.aspx page. The default.aspx page then redirects the user to the actual home page, according to the current site definition type, using the following sequence:

  1. The only content in default.aspx is a control that tells the runtime to use a RenderingTemplate called "MobileHomePageRedirect".

  2. The runtime searches all the *.ascx files in Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES for a RenderingTemplate with this name. It finds one in the MobileDefaultTemplates.ascx file.

  3. The Template property the of MobileHomePageRedirect control points the runtime to an object of the class SPMobileWebUrlRedirect.

  4. The SPMobileWebUrlRedirect object constructs the name of another RenderingTemplate using the pattern Mobile_SiteTypeID_HomePage_Redirect, where SiteTypeID is the name of a site definition that ships with Windows SharePoint Services, such as STS, or the ID number of a custom site definition, such as 10001. (For more information about mobile Web redirects, see the "Remarks" section in the SPMobileWebUrlRedirect topic.)

  5. The runtime searches all the *.ascx files in ...\12\TEMPLATE\CONTROLTEMPLATES for this second RenderingTemplate.

    • If SiteTypeID is BLOG, then the runtime will find the Mobile_BLOG_HomePage_RedirectRenderingTemplate in MobileDefaultTemplates.ascx. The latter control's Template property points the runtime to object of the class SPMobileUrlRedirection whose PageFileName property specifies that bloghome.aspx is the home page.

    • If SiteTypeID is not BLOG, and no custom .ascx files have been created, then the runtime will use the Mobile_Default_HomePage_RedirectRenderingTemplate in MobileDefaultTemplates.ascx. The latter control's Template property points the runtime to object of the class SPMobileUrlRedirection whose PageFileName property specifies that mbllists.aspx is the home page.

You can create a custom control that redirects users to an alternate mobile home page.

Procedures

Summary of process to customize the mobile home page through redirection

  1. Create a custom mobile home page; for example, MyHome.aspx.

  2. Place the new home page in the following directory:

    Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\MOBILE

  3. Create a custom control template file. For example, MyMobileControlTemplates.ascx (See example below.)

  4. Put the new control template in the following directory:

    Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES directory

  5. Reset Internet Information Services (IIS), and then browse to the Web site to see your customizations.

    Note

    If you are using a mobile device emulator on a computer, rather than an actual mobile device, you may need to delete temporary internet files each time you make a change in order to see the new version of the page.

Example

Description

The following example shows the contents of a custom .ascx file (for example, MyMobileControlTemplates.ascx) that defines a control template that directs the runtime to use MyHome.aspx as the home page whenever a mobile device accesses a Web site using the site definition "MySiteType". Notes about the custom file:

  • All of the "%@" directives are boilerplate such as that normally found in all such custom files.

  • The "MySiteType" can be:

    • The name of the team site definition: "STS". The MPS, CENTRALADMIN, and WIKI site definitions do not support access from mobile devices. The BLOG site definition can be accessed from mobile devices, but there is already a Mobile_BLOG_HomePage_RedirectRenderingTemplate defined in MobileDefaultTemplates.ascx. You may not modify this file. You can create a second RenderingTemplate also named Mobile_BLOG_HomePage_Redirect in a custom .ascx file, but doing so risks breaking other installed custom or third-party solutions that may depend on the existing Mobile_BLOG_HomePage_Redirect.

      Note

      The RenderingTemplates that ship with Windows SharePoint Services 3.0 load first, so the standard rendering template is overwritten when a custom template of the same name is loaded. If two or more custom RenderingTemplates have the same name, the one whose file name is alphabetically last will override the others. It a given file has two or more templates with the same name, none of them is loaded.

      Note

      The name of a site definition is set with the Name attribute of a Template element in a WebTemp.xml file. For more about the Name attribute of a site definition, see WebTemp.xml.

    • The ID number (not the name) of any custom site definition that has been created.

      Note

      The ID of a site definition is set with the ID attribute of a Template element in a WebTemp.xml file. For more about the ID attribute of a site definition, see WebTemp.xml.

Important

The site definition configuration's Configuration element in the site definition's Onet.xml file must have a WebFeatures element and that element must have the redirection feature element: <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4" />.

Code

<%@ Control Language="C#" %>
<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" %>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="SPMobile" Namespace="Microsoft.SharePoint.MobileControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<SharePoint:RenderingTemplate RunAt="Server" ID="Mobile_MySiteType_HomePage_Redirect">
  <Template>
    <SPMobile:SPMobileUrlRedirection RunAt="Server" PageFileName="MyHome.aspx" />
  </Template>
</SharePoint:RenderingTemplate>