在我的 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/