How to serve static files for your Single Page Application from .NET Core

This is post 5 of 10 in the series “ASP.NET Core from scratch using the command line” If you want to host your SPA app on .NET Core you’ll need to make sure your application is set up to serve your SPA’s static html and javascript files. First of all make sure you’ve got a .NET Core web application up …


The basics of publishing your .NET Core web app

There are lots of options for hosting your .NET Core application, especially now you can choose linux and take advantage of potentially cheaper hosting.
Whatever you choose, a useful first step is figuring out how to package up your app so you can publish it to your chosen host.


Compile your changes on the fly with .NET Core Watch

This is post 3 of 10 in the series “ASP.NET Core from scratch using the command line” You’ve set up your .NET Core web app, and maybe added MVC to it. As you work on your site, you’ll find yourself repeating the following over and over again. CTRL-C (to stop the application) This gets a little frustrating after a while. …


How to add MVC to your ASP.NET Core web application

This is post 2 of 10 in the series “ASP.NET Core from scratch using the command line” You’ve seen how to create your first simple web application using just the command line. Now let’s add MVC to the picture. Start off by modifying project.json to require the MVC packages. As with all dependencies, you’ll need to ensure it’s downloaded to …


Build your features

“How should I design my ASP.NET MVC Project?” You’re starting a greenfield ASP.NET MVC web site and you want to get it right so you start thinking about architecture. What folders should I have? where should my controllers go? Should I use AutoMapper and EntityFramework? Should I just pass my DataModels straight up to the view or map them to …


Use ASP.NET Core to cut the number of controllers in your web app

If you’ve ever built a Single Page Application on top of ASP.NET, you’ve probably found yourself creating a number of MVC controllers to serve your SPA’s initial views. These views then pull in all of your javascript code and references etc. In previous versions of ASP.NET, MVC and Web API controllers were separate so you’d often end up with two …


3 ways to spot if your controller is doing too much

It’s true, keeping your controllers thin is a good idea, but why? Imagine you need to do some work in an ASP.NET MVC application you’re unfamiliar with? Now imagine all the business logic is right there in the controller actions. Your job is to get a feel for the application, establish what’s already there and start working on a new …


Simplify your controllers with the Command Pattern and MediatR

This is post 1 of 2 in the series “Getting started with MediatR” So you want to keep your controllers thin even as your application becomes more and more complicated. You’re concerned that your controllers are getting bloated and you’ve heard people talk about the command pattern as one possible solution. But you don’t know how the command pattern would …


3 ways to keep your asp.net mvc controllers thin

You’ve been told that you should keep your asp.net controllers thin, that there shouldn’t be any logic in them, that testing controllers is pointless. But as your application becomes more complicated, so do your controllers. Now some pesky logic has infiltrated them and they’re looking suspiciously fat. Everyone’s advice is ringing in your ears, you know it’s probably bad to have logic in your controllers but there it is.

Here are three ways to reduce the logic living in your controllers.