I’m trying to understand the difference between self hosting and using asp.net core. My gut instinct tells me I get “more” with asp.net core vs self hosting, but if I’m not really using any of the asp.net core “stuff” and instead relying on ServiceStack, why would I not just self host? I will not be using any UI stuff from asp.net (razor, etc), just SPA (Vue) and I’m building a distributed micro service that will be run via Docker in any number of Linux EC2 instances on AWS (based on load). In this case, would self hosting be fine?
Self Host just means it uses the built-in Web Server, which is in contrast to classic ASP.NET Framework Web Apps which typically requires IIS or the built-in WebDev server to run.
All .NET Core Apps are self-hosting Console Apps where they use their own HTTP Server, instead of needing to rely on an external HTTP Server, although for deployment they’re typically hosted behind a full-featured reverse proxy like nginx to access to its more robust features like multiple Virtual Hosts behind a single domain, configuring SSL Certs, etc.
To clarify any confusion with the .NET Core Templates, the 2 empty templates are
They’re both self-hosting console Apps but the difference is that the selfhost .csproj contains only the minimum number of dependencies to run a .NET Core ServiceStack App, namely:
<ItemGroup> <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.*" /> <PackageReference Include="ServiceStack" Version="5.*" /> </ItemGroup>
Where as the
web project template contains the recommended starting dependency, namely the Microsoft.AspNetCore.App NuGet metapackage which contains 150 dependencies, which you don’t notice as most of them are bundled with the .NET Core installation.
<PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="ServiceStack" Version="5.*" />
All other .NET Core templates build upon the recommended
web .NET Core App template, which as it’s contains the recommended .NET Core Starting App template, it’s also what we recommend using.
So if you want to use Vue we recommend starting with any of the Vue .NET Core Templates which all utilize an npm based build system, or for a pure .NET only template you can start with the Vue “lite” template which is a pure .NET Core App that doesn’t require npm and as it leverages the bundling features in ServiceStack and TypeScript to build the App.
What you choose is a matter of preference, personally for small/medium projects I’d recommend starting with the vue-lite project template as it has the least complexity and moving parts and because it uses TypeScript it’s source-code compatible if you ever need to upgrade to a full npm Webpack build system.
Does the vue lite template tightly couple to the server side? I prefer to keep my back and front ends in separate projects and I use Visual Studio and VS Code, respectively.
I’m not sure what you mean by tightly coupled, all the UI is in the Host project like it is with every SPA project, the difference is whether ServiceStack does the bundling/minification or you want a separate npm WebPack based build to do it.
I typically use VS Code to author the UI client App in all my SPA projects since it has the best support for SPA formats like Vue’s SFC’s and run the TypeScript watch command in one of its terminal windows.
My preference for the C# ServiceStack back-end is to use JetBrain’s Rider.