SPWebApplication.UpdateMappedPage - Méthode

Met à jour le mappage de page d'application personnalisée.

Espace de noms :  Microsoft.SharePoint.Administration
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

'Déclaration
Public Function UpdateMappedPage ( _
    key As SPWebApplication.SPCustomPage, _
    newValue As String _
) As Boolean
'Utilisation
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
)

Paramètres

  • newValue
    Type : System.String

    L'emplacement de la page d'application personnalisée. Il doit commencer par « /_layouts/ ». Pour supprimer le mappage vers la page personnalisée, définissez la valeur de une référence Null (Rien dans Visual Basic).

Valeur renvoyée

Type : System.Boolean
true si la page d'application personnalisée est mappée avec succès ; dans le cas contraire, false.

Remarques

Le paramètre newValue est limité à un emplacement dans le dossier /_layouts. Lors de la mise à jour de la page mappée, l'URL doit commencer par « /_layouts/ ».

Exemples

L'exemple de code suivant montre comment mettre à jour le mappage à partir de la page d'application de AccessDenied.aspx par défaut pour une page d'application personnalisée et l'afficher sur la console. La page d'application d'origine est restaurée à la fin.

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

Voir aussi

Référence

SPWebApplication classe

SPWebApplication - Membres

Microsoft.SharePoint.Administration - Espace de noms