AngularJS SPA and .NET MVC routing

How hard can it be to do .NET MVC routing properly along with your AngularJS single page app? -Not very hard. Here is how you can do it:

MVC routing in RouteConfig.cs

Most of the guides you find tells you how to handle the routing if you wan’t to have your SPA routes with an app/ or angular/ prefix. For the sake of having as simple URLs as possible and Search Engine Optimization (SEO) you should avoid redundant stuff in URLs.
So what you want to do is to define the MVC Default route first to catch requests for your MVC controllers. In case the request doesn’t match any of your controllers, you should have a “fallback” CatchAllRoute that will hit your AngularController or whatever you have. Read more…

 

LESS with .NET bundling and minification (+Bootstrap)

There are two things you always have to do when building a website or web application: use a CSS preprocessor and bundle and minify your style/script resources. Using a preprocessor makes writing CSS not so horrible and bundling and minification gives you great performance advantages when you minimize your request amount and size.
Bundling and minification is usually done with grunt or gulp.js but in .NET environment you can take advantage of Microsoft ASP.NET Web Optimization Framework.

This guide will tell you how to use LESS as the CSS preprocessor along with bootstrap‘s LESS source and .NET bundling and minification. Read more…