简体   繁体   中英

Server Error in '/' Application. Cannot use a leading .. to exit above the top directory

I am trying to develop a C# web-based system with multiple user roles. Created in my project is sub-folders for Human Resources (HR), Finance and Contractors. In addition I am inheriting from the MaterPage which is in the root folder. This uses siteMaps. However, I am encountering this error when I try to access the folders. I have looked at the other examples and changed my code to use ~/ but still having the same error. Any help would be appreciated. Thanks.

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

HR Webconfig:

<?xml version="1.0"?>
  <configuration>
  <system.web>
    <authorization>
      <allow roles="Administrator"/>
      <allow roles="HR"/>
      <deny users="*"/>
    </authorization>
  </system.web>
</configuration>

Webconfig:

 <?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:

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>

HR Files

The positioning of the Bootstrap in the Master was wrong. I removed this and it worked by just placing it further down the CSS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM