app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa.Options.DefaultPage = "/app/";
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});
private readonly ValueComparer<ICollection<string>> valueComparer = new ValueComparer<ICollection<string>>(
equalsExpression: (c1, c2) => c1 != null && c2 != null && c1.SequenceEqual(c2),
hashCodeExpression: c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
snapshotExpression: c => c.ToHashSet());
public void Configure(EntityTypeBuilder<User> builder)
{
builder.Property(x => x.FavoriteStores)
.HasConversion(
to => string.Join(',', to),
from => from.Split(',', StringSplitOptions.None))
.Metadata
.SetValueComparer(valueComparer);
}
}
What am I doing wrong here Microsoft.AspNetCore.SignalR.HubException: Failed to invoke 'GetCategory' due to an error on the server.
? In my blazor's signalr client:
public Task<CategoryModel> GetCategory(int id)
{
var cancellationTokenSource = new CancellationTokenSource();
return _hubConnection.InvokeAsync<CategoryModel>("GetCategory", id, cancellationTokenSource.Token);
}
simplified in my aspnetcore signalr hub/server:
public async Task<CategoryModel> GetCategory(int id, CancellationToken cancellationToken)
{
return new CategoryModel((uint)id); // real version has dbcontext and such
}
I have working cases with StreamAsync
and SendAsync
, but InvokeAsync
has me scratching my head
app.UseSpa(spa =>
{
spa.Options.SourcePath = "ClientApp";
spa.Options.DefaultPage = "/app/";
if (env.IsDevelopment())
{
spa.UseReactDevelopmentServer(npmScript: "start");
}
});