Issue with self hosted netCore 2.0 console application and RazorFormat

I am trying to convert an existing full framework self hosted console app to net core 2.0. If I try to reference RazorFormat inside my apphost it throws an error stating I need to use services.AddMVC() to my Startup.cs file. How are we supposed to wire up razor support for self-hosted applications?

Have a look at how existing .NET Core Web App using Razor Format is configured.

1 Like

So there is no difference in setting up Razor between self-hosting and a web application then? I guess since net core web apps are just console apps that makes sense. Do you have any examples available as I couldn’t find anything.

.NET Core Apps are self-hosting Apps, what’s wrong with the above configuration?

Ok so the only reason to use AppSelfHostBase is when you want to do unit testing then? That seems to be where my confusion lies.

AppSelfHostBase is a wrapper in ServiceStack.Kestrel NuGet package that embeds its own Startup class and WebHost configuration to provide the same API to as AppSelfHostBase in .NET 4.5.

For .NET Core Web Apps it’s recommended to use the same configuration as you would to configure any .NET Core App.

Thanks for the assistance. Now I know, and knowing is half the battle :wink: