Web.config 中的站点地图问题
本文关键字:地图 问题 站点 config Web | 更新日期: 2023-09-27 17:55:29
Web.config 的问题。 siteMap 不起作用。VS2010.
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
<providers>
<add name="XmlSiteMapProvider"
description="Default SiteMap provider."
type="System.Web.XmlSiteMapProvider "
siteMapFile="Web.sitemap"
securityTrimmingEnabled="true" />
</providers>
</siteMap>
我认为它看不到"网站地图"。标签"add"中的智能感知建议仅锁定所有属性,锁定所有元素除外,锁定属性,锁定元素,锁定项 - 参数。但不建议参数描述,siteMapFile,securityTrimmingEnabled。
可能是什么原因?请指教。
Web.config 内容为:
<?xml version="1.0"?>
<configuration>
<connectionStrings>
<add name="SqlRoleManagerConnection"
connectionString="Data Source=server_name;Integrated Security=false;Initial Catalog=DB_XXX;User ID=User_XXX;Password=PASSWD_XXX"
providerName="System.Data.SqlClient" />
</connectionStrings>
<location path="Approver.aspx">
<system.web>
<authorization>
<allow roles="Approvers"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows"/>
<authorization>
<deny users="?"/>
</authorization>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
</providers>
</profile>
<roleManager enabled="true" defaultProvider="SqlRoleManager">
<providers>
<clear/>
<add name="SqlRoleManager" type="System.Web.Security.SqlRoleProvider" connectionStringName="SqlRoleManagerConnection" applicationName="HSE_Monitoring_Application" />
</providers>
</roleManager>
<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
<providers>
<add name="XmlSiteMapProvider"
description="Default SiteMap provider."
type="System.Web.XmlSiteMapProvider"
siteMapFile="Web.sitemap"
securityTrimmingEnabled="true" />
</providers>
</siteMap>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
网站地图内容是:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="default.aspx" title="Home">
<siteMapNode url="approver.aspx" title="Approver Expenses" roles="Approvers" />
<siteMapNode url="audit/auditor.aspx" title="Audit Page" roles="Auditors" />
<siteMapNode url="admin/admin.aspx" title="Admin Manager" roles="Admins" />
</siteMapNode>
</siteMap>
问候!
web.sitemap
文件是 ASP.NET 的默认站点地图提供程序,因此无需在web.config
中指定<siteMap ...
即可工作。此外,请考虑使用 ~/
作为路径的前缀:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/default.aspx" title="Home">
<siteMapNode url="~/approver.aspx" title="Approver Expenses" roles="Approvers" />
<siteMapNode url="~/audit/auditor.aspx" title="Audit Page" roles="Auditors" />
<siteMapNode url="~/admin/admin.aspx" title="Admin Manager" roles="Admins" />
</siteMapNode>
</siteMap>