Compartir a través de


Кастомизация страниц с ошибками

Sharepoint ????????? ??????????????? ???????? ? ????????. ?? ???? ???????? ?? ????????? ?????????, ????? ?????????? ?? ???? ??????. ??????? ? ?????? ???????? ??? ????????? ??????? ?? ??????? ?????. 

 

????, ? ??? ???? ????????? ??????????? ?? ???????????? ??????? ? ????????:

  • ?? ????? ????????? ???????? ??????? ??? ????????, ?????????????? ??? ????????????? ?????? 404.
  • ?? ????? ???????? ??????? ??? ???????? Access Denied, ?? ?????? ? ?????? ????????? ?? ?????? ???????? (master page).

??? ??? ??????? ?

 

?????? ?? ???????, ?? ???? c? ???????? ??? ?????? 404.

1. ?????????? ?????????? ????????, ??????? ?????????? ????? ???????? ? ????? %CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\ ? ????? ?? ??? ????? ???????? ??????????? ??????? ???????????? ? ??? ?? ???????. ? ????? ?????? ?? ????? ?????? ???????? ? ????? %CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\1033

???????? ???????? sps404. html ?????????? ??????????:

<html>

<head>

      <meta HTTP-EQUIV="Content-Type" content="text/html; charset=utf-8" />

      <meta HTTP-EQUIV="Expires" content="0" />

      <noscript>

            <meta http-equiv="refresh" content="0; url=/_layouts/spsredirect.aspx?noscript=1" />

      </noscript>

      <script language="javascript" type="text/javascript" src="/_layouts/1049/init.js"></script>

      <script language="javascript" type="text/javascript" src="/_layouts/1049/core.js"></script>

      <script language="javascript" type="text/javascript">

            var requestedUrl = escapeProperly(window.location.href);

            STSNavigate("/EN/Pages/404.aspx?oldUrl=" + requestedUrl);

      </script>

</head>

<body>

</body>

</html>

? STSNavigate ? ???????? ????????? ???? ??????? ?? ????? ???????? ??? ???? ???????.

2. ???????? ???????? 404. aspx ? ???????? ?? ? ?????????? ??????? ???????.

? ???? ?????????? ????????? ????????:

<%@ Page Language="C#" MasterPageFile="/_catalogs/masterpage/MySimple.master" inherits="Microsoft.SharePoint.WebPartPages.WebPartPage, Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" meta:progid="SharePoint.WebPartPage.Document" %>

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<asp:Content id="Content1" runat="server" contentplaceholderid="PlaceHolderPageTitleInTitleArea">

<SharePoint:EncodedLiteral ID="EncodedLiteral1" runat="server" text="<% $Resources: MySharePoint,myerror_404 %>" EncodeMethod='HtmlEncode'/>

</asp:Content>

<asp:Content id="Content2" runat="server" contentplaceholderid="PlaceHolderPageDescription">

<SharePoint:EncodedLiteral ID="EncodedLiteral2" runat="server" text="<% $Resources:MySharePoint,myerror_404_comment %>" EncodeMethod='HtmlEncode'/>

</asp:Content>

3. ???????? MySimple.master ??????? ??????????? ?? ????? %CommonProgramFiles%\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\simple.master ? ??????????? ???????? ???? ??? ???? ?????.

? ???? ?????????? ????????? ????????:

<%@ Master Language="C#" %>

<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"

    Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="MCSSPSS" Namespace="Microsoft.Services.SharePoint.Server.Search"

    Assembly="Microsoft.Services.SharePoint.Server.Search, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9f4da00116c38ec5" %>

<%@ Import Namespace="Microsoft.SharePoint" %>

<%@ Import Namespace="Microsoft.SharePoint.ApplicationPages" %>

<html id="HTML1" dir="<%$Resources:wss,multipages_direction_dir_value%>" runat="server">

<head id="HEAD1" runat="server">

    <meta name="GENERATOR" content="Microsoft SharePoint">

    <meta name="progid" content="SharePoint.WebPartPage.Document">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

    <meta http-equiv="Expires" content="0">

    <meta name="ROBOTS" content="NOHTMLINDEX">

    <title id="onetidTitle">

        <asp:contentplaceholder id="PlaceHolderPageTitle" runat="server" />

    </title>

    <SharePoint:CssLink ID="CssLink1" runat="server" Alternate="false" />

    <link rel="SHORTCUT ICON" href="/images/favicon.ico">

    <SharePoint:ScriptLink ID="ScriptLink1" Language="javascript" Name="core.js" runat="server" />

    <asp:contentplaceholder id="PlaceHolderAdditionalPageHead" runat="server" />

</head>

<body scroll="yes" onload="javascript:if (typeof(_spBodyOnLoadWrapper) != 'undefined') _spBodyOnLoadWrapper();">

    <form id="Form1" runat="server" onsubmit="return _spFormOnSubmitWrapper();">

        <div class="als_outer_width">

            <div class="als_outer_padding">

                <div class="als_full_width">

                    <!-- START: Header -->

                    <div class="als_hat_spacer">

                    </div>

<table class="als_layout" id="als_main">

                        <tr>

   <td class="als_layout als_left">

                            </td>

<!-- START: Content column -->

                            <td class="als_layout als_right">

                                <div id="als_logo">

                                                                        <a href='<SharePoint:EncodedLiteral runat="server" Text="<%$Resources:MySharePoint, myportal_error_logo_url %>"

                                    EncodeMethod="HtmlEncode" />'><img src='<SharePoint:EncodedLiteral runat="server" Text="<%$Resources:MySharePoint, myportal_logo_simple %>"

                                    EncodeMethod="HtmlEncode" />' /></a>

                                </div>

                                <div id="als_header" class="als_error_header">

                                    <h1 class="als_common">

                                        <asp:ContentPlaceHolder ID="PlaceHolderPageTitleInTitleArea" runat="server" />

                                    </h1>

                                </div>

                                <div class="als_content als_error_content">

                                    <div class="als_content_marginer">

                                        <p class="als_common">

                                            <asp:ContentPlaceHolder ID="PlaceHolderPageDescription" runat="server" />

                                        </p>

                                        <p class="als_common">

                              <asp:ContentPlaceHolder ID="PlaceHolderMain" runat="server">

                                            </asp:ContentPlaceHolder>

                                                                                      

                                        </p>

                                        <p class="als_common">

                                          

                                            <SharePoint:ReturnLink Text="<% $Resources:TnkBpSharePoint,tnkbperror_home %>" ID="ReturnLink1"

                                                runat="server" />

                                        </p>

                                    </div>

                                </div>

                            </td>

                            <!-- END: Content column -->

                        </tr>

                    </table>

                    <!-- END: Main area -->

                </div>

            </div>

        </div>

        <div style="display: none">

            <asp:ContentPlaceHolder ID="PlaceHolderGlobalNavigation" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderSiteName" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderSearchArea" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderTopNavBar" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="WSSDesignConsole" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="SPNavigation" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderPageImage" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderTitleLeftBorder" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderTitleAreaClass" runat="server">

                ms-areaseparator</asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderTitleBreadcrumb" runat="server">

                <SharePoint:ReturnLink Text="<%$Resources:wss,multipages_back_to_site%>" ID="idSimpleGoBackToHome"

                    runat="server" />

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderMiniConsole" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderTitleRightMargin" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderTitleAreaSeparator" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarDataSource" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderCalendarNavigator" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarTop" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderLeftNavBar" runat="server">

                &nbsp;

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderLeftActions" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderNavSpacer" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderLeftNavBarBorder" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderBodyLeftBorder" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderBodyAreaClass" runat="server">

                ms-formareaframe</asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderPageDescriptionRowAttr" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderPageDescriptionRowAttr2" runat="server" />

            <asp:ContentPlaceHolder ID="PlaceHolderBodyRightMargin" runat="server">

            </asp:ContentPlaceHolder>

            <asp:ContentPlaceHolder ID="PlaceHolderFormDigest" runat="server">

            </asp:ContentPlaceHolder>

        </div>

        <input type="text" name="__spDummyText1" style="display: none;" size="1" />

        <input type="text" name="__spDummyText2" style="display: none;" size="1" />

    </form>

    <asp:ContentPlaceHolder ID="PlaceHolderUtilityContent" runat="server" />

</body>

</html>

4. ???????? ??????. ?????? ???? ????????? Sharepoint ????????? ??? ????????????? ?????? 404 ???? ????????. ??? ???? ? ??????? SPWebApplication ???? ???????? FileNotFoundPage. ????? ???????? ???????, ??????? ?? url ??????? ????????? ??? ???? ???????? 404. ?????? ??? ???????? ???:

SPWebApplication webApplication = SPWebApplication.Lookup(new Uri(args[0]));

        webApplication.FileNotFoundPage = "sps404.html";

  webApplication.Update();

C 404 ??????? ?????????.

 

?????? ??? ???????? Access Denied. ?? ???????? ????? ?????? ??????? masterpage ??? ???? ????????. ???????? ?? ?????? ???????? ? ??? ???????? ??? MySimple.master ????????????? ? ?????????? ???????.

???????? ??? ????????? ???????:

1. ?????????? ??????? HttpModule ? ???????? ??? ????? ????????? ? web.config.

2. ? HttpModule ? ?????? page_PreInit ???????? ?????????:

Page page = sender as Page;

if (page != null)

{

//??? ????? ???????? ??? ?? ????????? ?? ?????? ????????

page.MasterPageFile = "/_catalogs/masterpage/mysimple.master";

}