SPSite.PortalName Property
Gets or sets the name of a portal. (Read-only in sandboxed solutions.)
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online
The following code example uses the PortalName property to establish a connection to a portal site from the specified site collection.
using (SPSite oSiteCollection = new SPSite("http://Server_Name/sites/Site_Name")) { oSiteCollection.PortalUrl = "http://Portal_Site/"; oSiteCollection.PortalName = "Portal_Name"; }
Note |
|---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |
PortalUrl and PortalName are read only
I am getting a compile error on this example for both PortalName and PortalUrl indicating they are read-only. Is the documentation on this incorrect?
Error 2 Property or indexer 'Microsoft.SharePoint.SPSite.PortalName' cannot be assigned to -- it is read only
Edit: ahhh, this happens only in a sandbox solution - in a farm solution it works just fine.
Error 2 Property or indexer 'Microsoft.SharePoint.SPSite.PortalName' cannot be assigned to -- it is read only
Edit: ahhh, this happens only in a sandbox solution - in a farm solution it works just fine.
Note