asp.net-mvc-3 - Site.css 为 Debug模式,site-min.css 为 Release模式

标签 asp.net-mvc-3 razor conditional-compilation

在我看来喜欢在debug模式下查看site.css使用她,而在release模式下编译查看时使用css-min.css site。

像这样:

# if (Debug)
             / / CSS
# elif (Release)
             / / CSS Min-
# endif

但在我看来.cshtml

最佳答案

您可以使用 Context.IsDebuggingEnabled。此 bool 属性由 web.config 中编译部分调试属性控制。

这是您的 view.cshtml 示例:

if (Context.IsDebuggingEnabled)
{
    // use something.css
}
else
{
    // use something.min.css
}

关于asp.net-mvc-3 - Site.css 为 Debug模式,site-min.css 为 Release模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7522840/

相关文章:

c++ - ifdef : is "#ifdef A && B" the same as "#if defined(A) && defined(B)"? 中的 bool 值

javascript - 提醒 Javascript 作为操作的返回响应

asp.net-mvc-3 - .NET MVC 3 提交按钮做不同的事情

asp.net-mvc-3 - 正在寻找能够与 MVC3 和 SQL Azure 良好配合的报告解决方案。有什么建议么?

asp.net-mvc - 我将如何编写一个 Action 过滤器来确保每个 Post 操作都使用防伪 token ?

rust - 如何根据编译功能标志为枚举添加生命周期

包裹在 ifdef 中的 Qt 信号

c# - 从下拉列表选择项中选择 ID 和名称时出错

javascript - 将 UTC 日期时间从服务器转换为网页上的本地日期时间

jquery - 从 JQuery 访问 MVC 3 Razor 对象值