ASP.NET Core 2: Environmental Tag Helpers

ASP.NET Core has a nice feature where different parts of your HTML will be rendered for different environment settings like Production and Development.

A great example is having JavaScript sent to the browser that is fully debuggable in development, but minified for production. Here’s how:

<environment names="Development">
    <script src="MyScript.js"></script>
</environment>
 
<environment names="Production,Staging">
    <script src="MyScript.min.js"></script>
</environment>

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s