MVC6 razor how to detect debug mode?
asp.net-core-mvc, asp.net-mvc, razor
Solution
In MVC6, you can use the environment tag helper to load different versions of scripts depending for Development vs Production environments. This is based on the value of the value of the ASPNET_ENV environment variable.
<environment names="Development">
<script src="~/debug.js"></script>
</environment>
<environment names="Staging,Production">
<script src="~/release.js"></script>
</environment>
Bundling and minification would be handled using a task like Gulp or Grunt.
I have outlined the new approach in detail here: http://www.davepaquette.com/archive/2015/05/05/web-optimization-development-and-production-in-asp-net-mvc6.aspx
Problem
In previous versions of Razor I would conditionally load minified/debug versions of scripts by rendering a partial view that looked something like this: ``` @if (Context.IsDebuggingEnabled) { <script src="~/debug.js"></script> } else { <script src="~/release.js"></script> } ``` If MVC6, vNext, VS2015, or whatever you call it :) I don't know how to accomplish this. Anyone know how?