SPWebApplication.UpdateMappedPage method
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Function UpdateMappedPage ( _
key As SPWebApplication.SPCustomPage, _
newValue As String _
) As Boolean
'用途
Dim instance As SPWebApplication
Dim key As SPWebApplication.SPCustomPage
Dim newValue As String
Dim returnValue As Boolean
returnValue = instance.UpdateMappedPage(key, _
newValue)
public bool UpdateMappedPage(
SPWebApplication.SPCustomPage key,
string newValue
)
參數
key
Type: Microsoft.SharePoint.Administration.SPWebApplication.SPCustomPage以取代指定的自訂應用程式] 頁面上的 [應用程式] 頁面。
newValue
Type: System.String自訂應用程式] 頁面上的位置。這必須以"/_layouts/"開頭。若要移除的對應至 [自訂] 頁面上,將值設定為a null reference (Nothing in Visual Basic)。
傳回值
Type: System.Boolean
true成功對應的自訂應用程式] 頁面上如果否則,請false。
備註
newValue參數僅限於 /_layouts 資料夾中的位置。更新 [對應] 頁面上時, URL 具有以"/_layouts/"為開頭。
Examples
下列程式碼範例示範如何更新預設 AccessDenied.aspx 應用程式] 頁面上的對應至自訂應用程式] 頁面上,並顯示至主控台。在結尾還原原始的應用程式] 頁面。
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
namespace MapCustomAppPage
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://MyServer"))
{
//Get a reference to the web application.
SPWebApplication webApp = site.WebApplication;
//Update AccessDenied application page to AxsDnd.aspx.
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/SubFolder/AxsDnd.aspx");
webApp.Update();
//Output the newly assigned application page.
Console.Out.WriteLine(webApp.GetMappedPage(SPWebApplication.SPCustomPage.AccessDenied));
//Reset the mapping to the default application page.
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, null);
webApp.Update();
Console.Out.WriteLine("Press any key...");
Console.ReadKey();
}
}
}
}
Imports System
Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.Administration
Module Module1
Sub Main()
Using site As New SPSite("http://MyServer")
'Get a reference to the web application.
Dim webApp As SPWebApplication = site.WebApplication
'Update AccessDenied application page to AxsDnd.aspx.
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, "/_layouts/SubFolder/AxsDnd.aspx")
webApp.Update()
'Output the newly assigned application page.
Console.Out.WriteLine(webApp.GetMappedPage(SPWebApplication.SPCustomPage.AccessDenied))
'Reset the mapping to the default application page.
webApp.UpdateMappedPage(SPWebApplication.SPCustomPage.AccessDenied, Null)
webApp.Update()
Console.Out.WriteLine("Press any key...")
Console.ReadKey()
End Using
End Sub
End Module