开发者

asp.net MVC - conditional compilation directly in aspx (site.master)?

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 RELE开发者_运维百科ASE 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 %>


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.


Check out http://haacked.com/archive/2007/09/16/conditional-compilation-constants-and-asp.net.aspx.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜