This topic has not yet been rated - Rate this topic

RobotsMetaTag Class

System.Object
  System.Web.UI.Control
    Microsoft.SharePoint.WebControls.SPControl
      Microsoft.SharePoint.WebControls.RobotsMetaTag

Namespace:  Microsoft.SharePoint.WebControls
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class RobotsMetaTag : SPControl
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
RobotsMetaTag renders nothing
The implementation in SharePoint 2010 has changes from the previous version. The control is most likely only included for backwards compatability. According to ILSpy the control is implemented like below, which means it doesn't render anything. Don't see any output from it if I check the rendered markup so nothing seems to be injected either.
 
I would therefore recommend remove it from your master pages.
 
namespace Microsoft.SharePoint.WebControls
{
 [SharePointPermission(SecurityAction.LinkDemand, ObjectModel = true), AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel = true), AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
 public class RobotsMetaTag : SPControl
 {
  [AspNetHostingPermission(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal), AspNetHostingPermission(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal), SharePointPermission(SecurityAction.Demand, ObjectModel = true), SharePointPermission(SecurityAction.Assert, ObjectModel = true)]
  protected override void Render(HtmlTextWriter output)
  {
  }
 }
}
RobotsMetaTag
Description

The Microsoft.SharePoint.WebControls.RobotsMetaTag class inherits from the Microsoft.SharePoint.WebControls.SPControl class which serves as the base server control for SharePoint WebControls. 

RobotsMetaTag is a reasonably unsophisticated control. When the control is rendering it will construct a SPWeb object using the current HttpContext and test whether the SPWeb.ASPXPageIndexed property is false. The ASPXPageIndexed property is responsible for relaying whether SharePoint WebForms are automatically indexed. 

The Usage Scenario

The most ordinary use of the RobotsMetaTag class is for derivation since it is common that users might not find the outputted meta tag to specifications. By default, this value output is CONTENT="NOHTMLINDEX" .

In the below sample, we are creating a new class that inherits from Microsoft.SharePoint.WebControls.RobotsMetaTag, and then manipulating its output.

C# Code Example

public class NewRobotsMetaTag : RobotsMetaTag 

protected override void Render(HtmlTextWriter writer) 

SPWeb web = GetContextWeb(HttpContext.Current); 
if (Equals(web.ASPXPageIndexed, false)) 

writer.Write("<META NAME=\"ROBOTS\" CONTENT=\"ChangedContent\"/>"); 


}

Visual Basic .NET Code Example

Public Class NewRobotsMetaTag
Inherits RobotsMetaTag
Protected Overloads Overrides Sub Render(ByVal writer As HtmlTextWriter)
Dim web As SPWeb = GetContextWeb(HttpContext.Current)
If Equals(web.ASPXPageIndexed, False) Then
writer.Write("<META NAME=""ROBOTS"" CONTENT=""ChangedContent""/>")
End If
End Sub
End Class

Adam Buenz
SharePoint Foundation MVP - http://www.sharepointsecurity.com