asp.net - 如何将 Visual Studio "compile"制作为 .aspx 文件?

标签 asp.net .net asp.net-mvc visual-studio

在我的 ASP.NET MVC 应用程序中,我有一个 .aspx 文件。我在 Visual Studio 2010 项目资源管理器树中选择它并转到文件属性 - 将“构建操作”设置为“内容”。我将“构建操作”更改为“编译”并要求 Visual Studio 构建项目。我在编译器输出中收到有关 .aspx 文件的以下错误消息:

C:\PathToProject\MyFile.aspx(1,1): error CS0234: The type or namespace name 'global_asax'
    does not exist in the namespace 'ASP' (are you missing an assembly reference?)

.aspx 文件的第一行是:

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/My.Master" Inherits="System.Web.Mvc.ViewPage" %>

这让我想知道......

编译器试图提示什么以及如何让它编译 .aspx 文件?

最佳答案

View 的 .aspx 必须将其“构建操作”设置为“内容”。

要在构建时启用预编译(或者至少是编译器错误检查),请添加

    <MvcBuildViews>true</MvcBuildViews>

到 .csproj 中的第一个

关于asp.net - 如何将 Visual Studio "compile"制作为 .aspx 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12496714/

相关文章:

asp.net - .NET 2.0 和 MySql 处于中等信任模式

javascript - 如何将 JavaScript 打包为 .NET Internet Explorer 9 插件?

c# - 如何使用 Windows API 将输入发送到 Visual Studio

javascript - 单击按钮以 mvc 形式触发模式弹出窗口

javascript - 名称 "document"在当前上下文中不存在,在布局页面中

asp.net-mvc - 如何在 asp.net mvc 中使用验证码

c# - 在不指定元数据端点的情况下使用 OpenIdConnect

c# - 如何使用 C# 从 iframe 访问父元素?

asp.net - 导入 SiteFinity

c# - 使用 WMI ChangeZoneType 将 DNS 区域从次要区域更改为主要区域