SPMobileWebUrlRedirect Class

Specifies, for a particular Web type (such as BLOG, STS, SGS, or a custom Web type), the ID of the <RenderingTemplate> that identifies the file that serves as the site's home page for mobile devices.

Namespace:  Microsoft.SharePoint.MobileControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public sealed class SPMobileWebUrlRedirect : SPMobileWebTemplateSelector

The <RenderingTemplate> ID has the following form.


The "Mobile" is a prefix that indicates that the <RenderingTemplate> is for mobile Web sites that do not use a Web Parts page as the home page.

The PageType is the type of page, such as HomePage or NewForm. But ordinarily HomePage is the only page type that ever needs to redirect mobile devices.

The "Redirect" indicates that <RenderingTemplate> identifies the URL of the page to which the mobile device should be redirected.

The WebSiteType portion of the ID is determined by the SPContext when the SPMobileWebUrlRedirect object is instantiated.

For built-in Web site types that ship with SharePoint Foundation, the WebSiteType is the value of the Name attribute of the Collaborative Application Markup Language (CAML) <Template Element (Site)> element (of the SharePoint WEBTEMP.XML file). For example, the Name value for the blog site definition is "BLOG". Hence, the SPMobileWebUrlRedirect object defines the following <RenderingTemplate> ID for a mobile blog home page.


For custom site definitions, the WebSiteType portion of the <RenderingTemplate>'s ID is the value of the ID attribute of the <Template Element (Site)> element (in a custom WEBTEMP*.XML file), not the Name attribute. Suppose you have a WEBTEMPMyCustomSiteDefinitions.XML file containing the following <Template Element (Site)> element.

<Template Name="MyFirstCustomSiteDefinition" ID="10001"> 

The SPMobileWebUrlRedirect object defines the following <RenderingTemplate> ID for the mobile home page.


The following is the portion of the MobileDefaultTemplates.ascx file (in %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\CONTROLTEMPLATES) that controls redirection for mobile devices.

Note that initially the MobileHomePageRedirect <RenderingTemplate> is called. It, in turn, calls the SPMobileWebUrlRedirect object. If the context is a BLOG site, the SPMobileWebUrlRedirect object defines Mobile_BLOG_HomePage_Redirect as the next <RenderingTemplate> to call and the mobile device is redirected to bloghome.aspx. In all other cases, if there are no custom site definitions, no <RenderingTemplate> with the name Mobile_WebSiteType_HomePage_Redirect (where WebSiteType is a Web site type other than BLOG) is found. So the <RenderingTemplate> named Mobile_Default_HomePage_Redirect is used, and it redirects the mobile device to mbllists.aspx.

<SharePoint:RenderingTemplate RunAt="Server" id="MobileHomePageRedirect">
    <SPMobile:SPMobileWebUrlRedirect RunAt="Server" />
<SharePoint:RenderingTemplate RunAt="Server" id="Mobile_Default_HomePage_Redirect">
    <SPMobile:SPMobileHomePageRedirection RunAt="Server" />
<SharePoint:RenderingTemplate RunAt="Server" id="Mobile_BLOG_HomePage_Redirect">
    <SPMobile:SPMobileHomePageRedirection RunAt="Server" PageFileName="bloghome.aspx" />

If there is a custom *.ascx file in the ...\CONTROLTEMPLATES folder that contains a <RenderingTemplate> with the name Mobile_WebSiteType_HomePage_Redirect (where WebSiteType is the ID number of a custom <Template Element (Site)>), then the page pointed to by that <RenderingTemplate> will be used.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.