SPWebApplication.UpdateMappedPage 方法
命名空间: Microsoft.SharePoint.Administration
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
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
类型:Microsoft.SharePoint.Administration.SPWebApplication.SPCustomPage要替换为指定的自定义应用程序页的应用程序页。
newValue
类型:System.String自定义应用程序页面的位置。这必须以"/_layouts/"开头。若要移除的映射到自定义页,可将它设置为空引用(无 在 Visual Basic 中)。
返回值
类型:System.Boolean
true如果成功映射自定义应用程序页 ;否则为false。
备注
newValue参数被限制为 /_layouts 文件夹中的某个位置。在更新时映射页,URL 将不得不以"/_layouts/"开头。
示例
下面的代码示例演示如何更新从默认的 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