【问题标题】:An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user codeSystem.Web.dll 中出现“System.Web.HttpException”类型的异常,但未在用户代码中处理
【发布时间】:2021-12-28 20:07:59
【问题描述】:

我在根目录的子目录中创建了 .aspx 文件。当我尝试访问它时,我得到了

An exception of type 'System.Web.HttpException' occurred in System.Web.dll but was not handled in user code
Additional information: The 'href' property had a malformed URL: Cannot use a leading .. to 
exit above the top directory..

当我尝试将 .aspx 的内容更改为纯文本时,它起作用了。但是当我把 ASP 标签放进去时,它没有。

代码如下:

<%@ Page Title="Articles!" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="12-28-2021_11-13AM.aspx.cs" Inherits="WebSite._1.Articles" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <hgroup class="title">
        <h1><%: Title %></h1>
    </hgroup>
</asp:Content>

我得到的答案之一是将“~”更改为“..”,但也没有用。

【问题讨论】:

    标签: c# asp.net


    【解决方案1】:

    看起来问题与 Site.Master 文件有关。 通过将 Site.Master 文件中的 href 中的“..”替换为“~”解决了问题。

    【讨论】:

      猜你喜欢
      • 2015-05-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-03-31
      • 2016-02-13
      • 2018-10-25
      • 2016-09-21
      • 1970-01-01
      相关资源
      最近更新 更多