C# '中的服务器错误/';应用无法使用前导。。在顶部目录上方退出

C# '中的服务器错误/';应用无法使用前导。。在顶部目录上方退出,c#,asp.net,C#,Asp.net,我正在尝试开发一个具有多个用户角色的基于C#web的系统。在我的项目中创建的是人力资源(HR)、财务和承包商的子文件夹。此外,我从根文件夹中的MaterPage继承。这将使用站点地图。然而,当我尝试访问文件夹时,我遇到了这个错误。我已经查看了其他示例,并将代码更改为使用~/但仍然存在相同的错误。任何帮助都将不胜感激。谢谢 Server Error in '/' Application. ________________________________________ Cannot use a l

我正在尝试开发一个具有多个用户角色的基于C#web的系统。在我的项目中创建的是人力资源(HR)、财务和承包商的子文件夹。此外,我从根文件夹中的MaterPage继承。这将使用站点地图。然而,当我尝试访问文件夹时,我遇到了这个错误。我已经查看了其他示例,并将代码更改为使用~/但仍然存在相同的错误。任何帮助都将不胜感激。谢谢

Server Error in '/' Application.
________________________________________
Cannot use a leading .. to exit above the top directory. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.Web.HttpException: Cannot use a leading .. to exit above the top directory.

Source Error: 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

Stack Trace: 

[HttpException (0x80004005): Cannot use a leading .. to exit above the top directory.]
   System.Web.Util.UrlPath.ReduceVirtualPath(String path) +12066575
   System.Web.Util.UrlPath.Reduce(String path) +60
   System.Web.UI.Control.ResolveClientUrl(String relativeUrl) +258
   System.Web.UI.HtmlControls.HtmlLink.RenderAttributes(HtmlTextWriter writer) +91
   System.Web.UI.HtmlControls.HtmlLink.Render(HtmlTextWriter writer) +65
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +79
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +250
   System.Web.UI.HtmlControls.HtmlHead.RenderChildren(HtmlTextWriter writer) +27
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +47
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +79
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +250
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +79
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +250
   System.Web.UI.Page.Render(HtmlTextWriter writer) +39
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +79
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +8753
人力资源网络配置:

<?xml version="1.0"?>
  <configuration>
  <system.web>
    <authorization>
      <allow roles="Administrator"/>
      <allow roles="HR"/>
      <deny users="*"/>
    </authorization>
  </system.web>
</configuration>
 <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <connectionStrings>
        <add name="constr" connectionString="Data Source=KANY-WEST\MSSQLSERVERKANY;Initial Catalog=OfficeSolutions;Integrated Security=True"/>
      </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <authentication mode="Forms">
          <forms defaultUrl="~/Home.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="2880"></forms>
        </authentication>
        <authorization>
          <deny users="?" />
        </authorization>
        <siteMap enabled ="true" defaultProvider="SiteMap">
          <providers>
            <add name="SiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Web.sitemap" securityTrimmingEnabled="true" />
          </providers>
        </siteMap>
      </system.web>
    </configuration>

网络配置:

<?xml version="1.0"?>
  <configuration>
  <system.web>
    <authorization>
      <allow roles="Administrator"/>
      <allow roles="HR"/>
      <deny users="*"/>
    </authorization>
  </system.web>
</configuration>
 <?xml version="1.0"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <connectionStrings>
        <add name="constr" connectionString="Data Source=KANY-WEST\MSSQLSERVERKANY;Initial Catalog=OfficeSolutions;Integrated Security=True"/>
      </connectionStrings>
      <system.web>
        <compilation debug="true" targetFramework="4.0"/>
        <authentication mode="Forms">
          <forms defaultUrl="~/Home.aspx" loginUrl="~/Login.aspx" slidingExpiration="true" timeout="2880"></forms>
        </authentication>
        <authorization>
          <deny users="?" />
        </authorization>
        <siteMap enabled ="true" defaultProvider="SiteMap">
          <providers>
            <add name="SiteMap" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Web.sitemap" securityTrimmingEnabled="true" />
          </providers>
        </siteMap>
      </system.web>
    </configuration>

网站地图:

SiteMap:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
  <siteMapNode url="" title="Home" description="" roles ="*">
    <siteMapNode url="~/Home.aspx" title="Home" description="Home Page"  roles="*" />
    <siteMapNode url="javascript:;" title="Admin" description="Admin Page" roles ="Administrator">
      <siteMapNode url ="~/Admin/Users.aspx" title="Users" description="Users Page"></siteMapNode>
      <siteMapNode url ="~/Admin/Reports.aspx" title="Reports" description="Reports Page"></siteMapNode>
    </siteMapNode>
       <siteMapNode url="~/Contact.aspx" title="Contact" description="Contact Us Page"  roles="*" />
       <siteMapNode url="~/ViewMessages.aspx" title="Dash Board" description="Message Dash Board"  roles="*" />
       <siteMapNode url="~/CreateNewMessage.aspx" title="New Message" description="Create New Message"  roles="*" />
       <siteMapNode url="~/HR/HR.aspx" title="HR" description="HR"  roles="HR" />
       <siteMapNode url="~/Finance/Finance.aspx" title="Finance" description="Finance"  roles="Finance" />
       <siteMapNode url="~/Contractors/Contractors.aspx" title="Contractors" description="Contractors"  roles="Contractors" />
  </siteMapNode>
</siteMap>
站点地图:
HR.aspx

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.Master" AutoEventWireup="true" CodeBehind="HR.aspx.cs" Inherits="MessagingSolutions.HR.HR" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<h1>HR Files</h1>
</asp:Content>

人力资源档案

人力资源档案

引导程序在主程序中的定位错误。我删除了它,只需将它放在CSS的下面就可以了。

我建议在代码库中搜索
。根据堆栈跟踪,您有
System.Web.UI.HtmlControls.htmlink
抛出异常,因为路径使用中存在
。\
~/
(页面本身已经在根级别)。请尝试提供导致错误的页面的详细标记。@TetsuyaYamamoto my page继承自母版页。但是,标记如下:尝试删除页面定义中的平铺,以便母版页成为
MasterPageFile=“MasterPage.master”
。能否提供站点文件夹层次结构以确保母版页链接良好?