【问题标题】:< !--#include virtual="feed.asp"--> is not working for Page.cshtml file< !--#include virtual="feed.asp"--> 不适用于 Page.cshtml 文件
【发布时间】:2025-11-24 23:00:02
【问题描述】:

我正在尝试将 feed.asp 嵌入到 Page.cshtml 中。但它不会编译命令。这是页面的代码。

@{

}

<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title>ONC Project Tracking</title>
        <style type="text/css">
        .auto-style1 {
            text-align: center;
            font-family: Verdana, Geneva, Tahoma, sans-serif;
            font-weight: bold;
            color: #800000;
        }
        .auto-style2 {
            text-align: justify;
            font-family: Verdana, Geneva, Tahoma, sans-serif;
        }
        .auto-style3 {
            font-family: Verdana, Geneva, Tahoma, sans-serif;
        }
        .auto-style4 {
            text-align:center;
            margin-left:auto;
            margin-right:auto;
            border: 0px solid black;
        }
        .auto-style4 tr {
            width: 30%;
        }
        .auto-style4 td {
            border: 0px solid black;
            padding: 0px;
            border-collapse:collapse;
            border-spacing: 0px;
        }
        .auto-style5 {
            max-width: 50%;
        }
        .auto-style11 {
            width: 1077px;
            height: 283px;
        }

    </style>
    </head>
    <body>
        <p class="auto-style1">
        Welcome to the ONC project tracking JIRA system</p>
    <p>
        &nbsp;</p>
    <p class="auto-style2">
        Welcome to the ONC project tracking JIRA system. The Nationwide Health Information Network Division of the Office of National Coordinator maintains the system to provide a collaborative environment for the healthcare industry to implement meaningful use requirements. Below please find links to numerous projects that are hosted on the project tracking system, as well as a summary of the hot topics being discussed. Within each project you will find conversations related to implementing specific meaningful use measures.</p>
    <p class="auto-style3">
        If you have questions about meaningful use direct them to <a href="mailto:mindy.hangsleben@hhs.gov">mindy.hangsleben@hhs.gov</a>. If you&#39;re having technical problems with this site please contact onc-jira@ainq.com.</p>

        <hr>

    <table class="auto-style4">
        <tr>
            <td>
                <img alt="" class="auto-style5" src="high-priority-tickets-button.png" /></td>
            <td>
                <img alt="" class="auto-style5" src="hot-tickets-button.png" /></td>
            <td>
                <img alt="" class="auto-style5" src="issues-due-this-week-button.png" /></td>
        </tr>
        <tr>
            <td>
                <img alt="" class="auto-style5" src="create-a-ticket-button.png" /></td>
            <td>
                <img alt="" class="auto-style5" src="latest-tickets-button.png" /></td>
            <td>
                <img alt="" class="auto-style5" src="my-new-tickets-button.png" /></td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td>
                <img alt="" class="auto-style5" src="my-profile-button.png" /></td>
            <td>&nbsp;</td>
        </tr>
    </table>



   < !--#include virtual="feed.asp"-->

    </body>
</html>

输出有''而不是渲染asp页面的内容。

【问题讨论】:

  • 你想在razor cshtml中嵌入一个经典的asp页面吗?
  • 不要在 ASP.NET 中使用服务器端包含。在经典 ASP 时代,它们是一个坏主意,而现在它们是一个更糟糕的主意。
  • 您正尝试同时使用两种不同的服务器端技术。这是行不通的。

标签: asp.net razor


【解决方案1】:

这行不通。

如果您绝对必须包含此 asp 文件,请尝试使用&lt;iframe&gt; - 但即便如此,您也很难让 asp 在 IIS7 中运行(假设应用程序在 IIS7 上运行)

【讨论】:

    【解决方案2】:

    我假设您的项目是某种 ASP.NET C# Web 应用程序(MVC、站点或其他)。这意味着您的默认页面语言是 C#。如果您能够让服务器端包含工作,编译器会期望包含的文件也是相同的语言。你不能混合和匹配语言。

    我通过 .ASP 扩展名假设文件源是经典 ASP 时代的 VBScript?如果是这样,您将无法结合经典的 ASP 和 ASP.NET。

    如果由于某种原因 feed.asp 是一个带有经典扩展名的 .NET 文件,Response.WriteFile("myFile.aspx") 是一种包含另一个文件的方法,但我相信这个文件也需要在 C# 中。如果你使用 MVC,你可以使用 Html.RenderPartial

    一些资源供您阅读:

    ASP.NET equivalent of server side includes

    http://support.microsoft.com/kb/306575

    【讨论】: