Search code examples
c#asp.netasp.net-coreavaloniaui

Is it possible to run a DOTNET Core WebAPI asynchronously in an AvaloniaUI Project?


I'm working on a project where I'm creating an AvaloniaUI frontend which would be able to be managed remotely via a REST API. In order to solve this, I created an Avalonia application, then added an additional project to the solution using the 'ASP.NET Core API' template.

I used the following question as a template for setup:

Hosting ASP.NET Core API in a Windows Forms Application

Here they have a similar use case, however with a winforms project rather than Avalonia.

Program.cs:

enter image description here

Startup.cs

enter image description here

When the API project starts async, the server doesn't seem to be running as it refuses the connection. The only way I have been able to get it to respond to get requests has been to set the API project as the startup project (before I had made the changes to Program.cs).

Any help at all will be appreciated, I'm relatively inexperienced when it comes to ASP.NET, so I apologise if this is a relatively simple issue.


Solution

  • I have found the solution. Turns out that the server was successfully running, however due to the fact that I didn't have and SSL certificate, the server would not accept the connection except on the unsecured 5001 port.