Just learning ASP.NET Core now and in some guides I see app.UseEndpoints() method.
But when I created my ASP NET CORE Project I've only seen app.Run in StartUp.cs
app.UseEndpoints(endpoints => { endpoints.MapHub<ChatHub>("/chat"); });
If you are using Net Core 2.1, you have to configure it that way:
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SignalRChat.Hubs;
namespace SignalRChat
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddSignalR();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSignalR(routes =>
{
routes.MapHub<ChatHub>("/chat");
});
app.UseMvc();
}
}
}
Only afrer version 3.0 you can use app.UseEndpoints
app.UseEndpoints(endpoints =>
{
endpoints.MapHub<ChatHub>("/chat");
});
See docs:
ASP.NET Core 2.1
ASP.NET Core 3.0 +
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With