SignalR
SignalR is an ASP.NET Core library that allows server-side code to be instantly pushed to the client.
Prerequisites
- Visual Studio 2019 or higher
- Azure account (to publish SignalR service)
Steps
Create
ASP.NET Core web application
in Visual Studio and name itUnoChat.Service
.Add SignalR Hub to your
[YourProjectName].Service
project in aHubs
folder.In your
Startup.cs
file, add yourSignalR
service and aCORS policy
to theConfigureServices
method.public void ConfigureServices(IServiceCollection services) { services.AddRazorPages(); services.AddSignalR(); services.AddCors(o => o.AddPolicy( "CorsPolicy", builder => builder .AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader() )); }
In your
Configure
method, add your CORS policy andHubs
endpointapp.UseCors("CorsPolicy"); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); endpoints.MapHub<Hubs.[YourProjectHub]>("/yourProjectHub"); });
You now have a SignalR service that you can use with your Uno application!