asp.net MVC - 直接在aspx(site.master)中进行条件编译?
我似乎直接在我的 site.master 中遇到了条件编译标签的问题。
基本上我有以下内容,但它在编译器中报告“无法解析符号调试”,尽管我可以在调试和发布中运行...但是最终输出总是打印 DEBUG 天气中的内容,我处于 RELEASE 或 DEBUG 状态...
正如前面提到的,编译器不会抱怨,但它在调试时有一些红线,并带有错误消息。我做错了什么?有人可以帮忙吗?
<%@ 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 %>
I seem to be having an issue with the conditional compilation tags directly en my site.master..
basically i have the following but it reports "Cannot resolve symbol DEBUG" in the compiler alhough i can run in DEBUG and RELEASE ... but the final output always prints whats in DEBUG weather i am in RELEASE or DEBUG...
And as mentioned the compiler doesn't complain but it has little red lines under debug with the error msg.. What am i doing wrong? Can anyone help?
<%@ 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 %>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我从未在 aspx 页面中使用过条件编译标记,但我对可能出现的问题有一个想法。当您说“在 DEBUG 中运行”或“在 RELEASE 中运行”时,您到底是什么意思?您如何将其设置为调试或发布模式?如果您只是将 Visual Studio 设置为进行调试/发布构建,则这不适用于 aspx 页面的编译方式。 aspx 页面是否以调试/发布模式编译仅取决于页面标题中的设置或 web.config 中的设置。
I've never used the conditional compilation tags in aspx pages, but I have one idea on what might be wrong. When you say "run in DEBUG" or "run in RELEASE", exactly what do you mean? How are you setting it to debug or release mode? If you're just setting Visual Studio to do a debug/release build, that doesn't apply to how the aspx pages are compiled. Whether aspx pages are compiled in debug/release mode depends only on settings in the page header or settings in the web.config.
查看 http://haacked.com /archive/2007/09/16/conditional-compilation-constants-and-asp.net.aspx。
Check out http://haacked.com/archive/2007/09/16/conditional-compilation-constants-and-asp.net.aspx.