Метод SPSite.OpenWeb

Returns the Web site that is associated with the URL that is used in an SPSite constructor.

Пространство имен:  Microsoft.SharePoint
Сборка:  Microsoft.SharePoint (в Microsoft.SharePoint.dll)

Синтаксис

'Декларация
Public Function OpenWeb As SPWeb
'Применение
Dim instance As SPSite
Dim returnValue As SPWeb

returnValue = instance.OpenWeb()
public SPWeb OpenWeb()

Возвращаемое значение

Тип: Microsoft.SharePoint.SPWeb
An SPWeb object that represents the Web site.

Замечания

When used in conjunction with an SPSite constructor, the OpenWeb method returns the lowest-level site specified by the URL that is passed as parameter for the constructor. For more information about using the OpenWeb method with an SPSite constructor, see the OpenWeb method overload.

Примеры

The following code example returns the Web site that is located at https://Server_Name/sites/Site_Name/Subsite_Name.

Dim strUrl As String = "http://Server_Name/sites/Site_Name/Subsite_Name/default.aspx"
Using oSiteCollection As New SPSite(strUrl)
    Using oWebsite As SPWeb = oSiteCollection.OpenWeb()
        ...
    End Using
End Using
string strUrl = 
   "http://Server_Name/sites/Site_Name/Subsite_Name/default.aspx";
using (SPSite oSiteCollection = new SPSite(strUrl))
{
    using(SPWeb oWebsite = oSiteCollection.OpenWeb())
    {
        ...
    }
}

Примечание

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.

См. также

Справочные материалы

SPSite класс

Элементы SPSite

Перегрузка OpenWeb

Пространство имен Microsoft.SharePoint