Encosia - ASP.NET, AJAX, jQuery, and more

Bring Less back to Visual Studio 2015 without gulp or grunt

CSS, Visual Studio By . Updated August 31, 2015

Back to the drawing board...

Microsoft recently announced the official release of Visual Studio 2015. It’s faster and offers some nice new features like the Roslyn API for Intellisense and refactorings, ES2015 syntax support, and (most importantly) finally reverts those ALL CAPS MENUS back to Title Casing.

However, you may notice another change if you’ve been using Web Essentials to transpile Less to CSS in Visual Studio 2013. One of the first things you may notice about Visual Studio 2015 is that Web Essentials 2015 has dropped that feature entirely.

That leaves you in an interesting predicament after upgrading to Visual Studio 2015. The official line is that you should update your project to use the new Task Runner Explorer along with grunt or gulp for tasks like Less compilation and CSS minification. That’s a bit of a speed bump though.

I’m a proponent of using task runners like grunt and gulp (In fact, I’ve been using grunt to build this site’s client-side assets for years), but it doesn’t make sense to invest in converting all of my existing projects over to the new paradigm immediately. That’s especially true of client projects, where I can’t move an entire team to a new toolchain and workflow overnight.

However, after using Visual Studio 2015 daily for several months, I would be an unhappy camper if I could only use Visual Studio 2013 and Web Essentials 2013 to maintain those existing projects.

So, in this post I want to show you the solution I’m using to keep Less compilation working in those existing projects, without Web Essentials or any other plugins.
Click here to read the rest of this post »

Canonical URLs in IIS without breaking localhost debugging

ASP.NET, Azure, Visual Studio By . Posted April 30, 2014

It’s important that public-facing websites respond to requests for both domain.tld and www.domain.tld. You can’t control what your users will type into their browsers and you never know which form of your site’s URL people will use in links that they share in email, social media, and links on their own sites. Of course, you want to be sure that your website responds even if they don’t use your preferred version of your URL.

However, it’s nearly as important that all of those requests are redirected to just one address for SEO purposes. This is known as choosing and enforcing a canonical URL. If you don’t enforce a canonical URL and a search engine indexes duplicate copies of your content, you risk diluting the authority that backlinks have given your content and you even risk incurring the dreaded duplicate content penalty. Both will impact how your content fares in search result rankings.

Though rel="canonical" and improvements to search engine algorithms have helped reduce unwarranted penalties related to this mistake, the risk of unnecessarily falling behind in the rankings is too great to ignore.

To solve that problem, many websites running on IIS make use of its built-in rewrite module to enforce a canonical domain name. Unfortunately, the most obvious way to accomplish that ends up causing trouble when you want to work with the site locally.

Click here to read the rest of this post »