App_Code/Providers/CustomXmlSitemapProvider.cs
(开头部分) 5KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
//===============================================================================================
//
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Permissive License.
// See http://www.microsoft.com/resources/sharedsource/licensingbasics/sharedsourcelicenses.mspx.
// All other rights reserved.
//
//===============================================================================================
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace MyWebPagesStarterKit.Providers
{
/// <summary>
/// Specialized XmlSiteMapProvider that implements some special behaviour
/// </summary>
public class CustomXmlSitemapProvider : XmlSiteMapProvider
{
/// <summary>
/// Special IsAccessibleToUser method (see code to get further explanations)
/// </summary>
public override bool IsAccessibleToUser(HttpContext context, SiteMapNode node)
{
//if SecurityTrimming is disabled, ALL nodes are accessible by everyone
if (!SecurityTrimmingEnabled)
return true;
//Administrators have permissions on all nodes, so we can always return true
if ((context.User != null) && (context.User.Identity.IsAuthenticated) && context.User.IsInRole(RoleNames.Administrators.ToString()))
return true;
//The RootNode must be accessible for everyone
if (node.ParentNode == null) //if there is no parent-node, the node must be the root node
return true;
//special behaviour for nodes that have a pageId attribute (content-pages)
if (node["pageId"] != null)
{
//first we create the WebPage for the node
WebPage page = new WebPage(node["pageId"]);
//now check, if we have a logged in user (in role Users)
if ((context.User != null) && context.User.Identity.IsAuthenticated)
{
//we have a authenticated user, therefore the only thing that counts is, if the page is visible
return page.Visible;
}
else
{
//anonymous user -> we must check if the page is visible, and if it allows anonymous access
return ((page.Visible) && (page.AllowAnonymousAccess));
}
}
后面还有 55 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。
