There is a recurring topic when you start developing with AngularJS and Asp.Net: do I use Razor for generating my views or just static HTML?
As an Asp.NET developer myself, I see the tendency in going with the former: after all, that is what you’ve being doing so far and it just works, the Razor syntax is great, plus things like localizing your views are a piece of cake. But there’s more than meets the eye, and that is what’s going to bite you down the road.
Let me underline a few key points:
- There’s no way of accessing your Razor views directly from the server, so you’ll have to resort to a custom controller just to serve your AngularJS templates as partial views.
- Once you go down the path of dynamically serving your views, you lose the ability to use a CDN to cache those views (only static content can be served through a CDN). Static HTML is more easily cached by the browser, too.
So there is plenty of benefits in hosting your AngularJS app with Asp.NET MVC, IIS and all the great tooling that comes with them. Just treat your AngularJS templates like regular HTML, and serve them as static content publicly accessible or bundled together.
I hope this gives you some more insights on the topic.