Search code examples
asp.net-mvc-3razorconditional-compilation

Site.css to Debug mode, site-min.css to release mode


In my view like that in debug mode to view Site.css use her, and when compiled in release mode the view using CSS-min.css site.

Something like this:

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

But in my view .cshtml


Solution

  • You can use Context.IsDebuggingEnabled. This boolean property is controlled by the debug attribute from the compilation section in web.config.

    Here's a sample for your view.cshtml :

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