Open mcbridd opened 3 years ago
Not sure what Razor has to do with this, but I can confirm this example doesn't seem to work in .NET Core 3.1. It looks like the hosted service is started before Configure is called.
The StartAsync method is async, but ASP.NET Core will wait around for us to start before doing anything else (boo!) but we can just spin off a new task and wait there.
public Task StartAsync(CancellationToken cancellationToken) {
Task.Run(this.GoAsync);
return Task.CompletedTask;
}
private async Task GoAsync() {
while (ServerAddresses == null) {
await Task.Delay(250);
}
/* same as before, but remove the return Task.CompletedTask */
This works for me, of course it's even more of a hack than before now.
Hi,
I really appreciate people who put their time into producing code like this to help people like myself, but every time I find a useful example, it has been broken by changes to .NET Core versioning. In this case, the DefaultRazorPageFactoryProvider class and other Razor classes have now been changed to Internal in .NET Core 3.0, making them inaccessible.
Trying to figure out a way around it as I type.
Thanks, Darren