【问题标题】:asp.net MVC - conditional compilation directly in aspx (site.master)?asp.net MVC - 直接在aspx(site.master)中进行条件编译?
【发布时间】:2010-11-22 16:34:21
【问题描述】:

我的 site.master.. 中的条件编译标签似乎有问题。

基本上我有以下内容,但它在编译器中报告“无法解析符号调试”虽然我可以在调试和发布中运行......但最终输出总是打印我在发布或调试中的调试天气中的内容......

如前所述,编译器没有抱怨,但它在调试时有一些红线,并带有错误消息。我做错了什么?有人可以帮忙吗?

<%@ Master Language="C#" Inherits="System.Web.Mvc.ViewMasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title><asp:ContentPlaceHolder ID="TitleContent" runat="server" /></title>

    <% #if DEBUG %>
    <link href="../../Content/CSS/test.css" rel="stylesheet" type="text/css" />
   <script src="../../Content/Scripts/jquery-1.3.2.js" type="text/javascript">     
    </script>    
   <% #else %>
   <link href="../../Content/CSS/StyleSheetFinal.css" rel="stylesheet" type="text/css" />
   <script src="../../Content/Scripts/JavascriptFinal.js" type="text/javascript"></script>
   <% #endif %>

【问题讨论】:

标签: asp.net asp.net-mvc conditional-compilation


【解决方案1】:

我从未在 aspx 页面中使用过条件编译标签,但我对可能出现的问题有一个想法。当您说“在 DEBUG 中运行”或“在 RELEASE 中运行”时,您究竟是什么意思?您如何将其设置为调试或发布模式?如果您只是将 Visual Studio 设置为进行调试/发布构建,则不适用于 aspx 页面的编译方式。是否在调试/发布模式下编译 aspx 页面仅取决于页眉中的设置或 web.config 中的设置。

【讨论】:

  • 谢谢...啊,是的,我只是在 DEBUG 或 RELEASE 中编译,这是哪个设置?? web.config 的哪一部分?我假设在 release 中编译也会在 RELEASE 中编译所有内容?
  • 啊,我明白了.. 它的工作原理......所以这实际上意味着什么.. 我所有的 dll 在我编译时都是根据 Release/Debug 编译的,但是 web 项目是根据 web 编译的.config 项??
  • 对不起,我没有早点回来查看。 Visual Studio 仅编译所有 *.cs(或 *.vb)文件,因此 Visual Studio 中的设置仅适用于这些文件。 *.aspx 页面由 Web 服务器编译。 web服务器查看web.config中的configuration/system.web/compilation/@debug,看是否需要在debug模式下编译。
【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-01
  • 1970-01-01
  • 1970-01-01
  • 2017-02-08
  • 1970-01-01
相关资源
最近更新 更多