0

Web.config 的问题。站点地图不工作。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> 

我认为它没有看到“Web.sitemap”。标记“添加”中的智能感知仅建议 lockAllAttributesExcept、lockAllElementsExcept、lockAttributes、lockElements、lockItem - 参数。但不建议参数描述、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>

Web.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>

带着敬意!

4

1 回答 1

0

The web.sitemap file is the default site-map provider for ASP.NET, so it will work without specifying the <siteMap ... in web.config. Also, consider using ~/ as a prefix on your paths:

<?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>
于 2013-01-22T14:59:27.420 回答