blazor

Can you use IAsyncEnumerable in Razor pages to progressively display markup?

社会主义新天地 提交于 2020-06-10 16:49:28
问题 I've been playing around with Blazor and the IAsyncEnumerable feature in C# 8.0. Is it possible to use IAsyncEnumerable and await within Razor Pages to progressively display markup with data? Example service: private static readonly string[] games = new[] { "Call of Duty", "Legend of Zelda", "Super Mario 64" }; public async IAsyncEnumerable<string> GetGames() { foreach (var game in games) { await Task.Delay(1000); yield return game; } } Example in razor page: @await foreach(var game in

Is there an equivalent to Html.Raw in Blazor?

一个人想着一个人 提交于 2020-06-10 07:20:18
问题 I have some HTML that is stored in a string. How can I render this is a Blazor/Razor view without automatic HTML encoding? 回答1: Feature to render raw HTML was added in Blazor 0.5.0 version. This is the example of how raw HTML can be rendered from string containing HTML content: @((MarkupString)myMarkup) @functions { string myMarkup = "<p class='markup'>This is a <em>markup string</em>.</p>"; } More info can be found in "Blazor 0.5.0 experimental release now available" announcement. 回答2: Not

How do I pass returnUrl to Login page in Blazor Server application?

爷,独闯天下 提交于 2020-06-01 10:56:50
问题 I have a simple Blazor server application, with Identity using Individual Authentication. I created the app from the VS 2019 standard dotnet new template. In some parts of the app I would like to direct the user to the login page, while passing along a returnUrl parameter. I've tried the following variations of code to pass this parameter ( counter is the page I want to return to): NavigationManager.NavigateTo("Identity/Account/Login?returnUrl=counter", forceLoad: true); NavigationManager

How do I pass returnUrl to Login page in Blazor Server application?

倾然丶 夕夏残阳落幕 提交于 2020-06-01 10:55:53
问题 I have a simple Blazor server application, with Identity using Individual Authentication. I created the app from the VS 2019 standard dotnet new template. In some parts of the app I would like to direct the user to the login page, while passing along a returnUrl parameter. I've tried the following variations of code to pass this parameter ( counter is the page I want to return to): NavigationManager.NavigateTo("Identity/Account/Login?returnUrl=counter", forceLoad: true); NavigationManager

How to get JWT authenticated sign-in user from identity claims in asp.net web api

倖福魔咒の 提交于 2020-06-01 09:49:06
问题 I implemented a JWT token authentication where the register and login are working fine. This is what I normally do with inbuilt authentication var currentUser = await _userManager.GetUserAsync(HttpContext.User); var category = _context.Categories.Where(m=>m.ApplicationUserId == currentUser.Id); return View(await category.ToListAsync()); I will get the current logged in user from the httpContext, then match the current user id(that is the application user Id of the current user) with the

In Blazor, how do I make changes to an injected object be reflected in all components? (AKA reactivity)

两盒软妹~` 提交于 2020-05-31 08:59:42
问题 In a Blazor WebAssembly site, suppose I have a class public class State : IState { public bool ShowEasterEggs { get; set; } = false; } And I properly register it in my client's Program.cs: builder.Services.AddSingleton<IState, State>(); And I properly inject this into a component: @inject IState State @if (State.ShowEasterEggs) { <span>EASTER EGGS SHOWN</span> } And in some other component, I enable a change to it: @inject IState State <input type="checkbox" @bind="State.ShowEasterEggs"/>Show

In Blazor, how do I make changes to an injected object be reflected in all components? (AKA reactivity)

Deadly 提交于 2020-05-31 08:53:07
问题 In a Blazor WebAssembly site, suppose I have a class public class State : IState { public bool ShowEasterEggs { get; set; } = false; } And I properly register it in my client's Program.cs: builder.Services.AddSingleton<IState, State>(); And I properly inject this into a component: @inject IState State @if (State.ShowEasterEggs) { <span>EASTER EGGS SHOWN</span> } And in some other component, I enable a change to it: @inject IState State <input type="checkbox" @bind="State.ShowEasterEggs"/>Show

In Blazor, how do I make changes to an injected object be reflected in all components? (AKA reactivity)

非 Y 不嫁゛ 提交于 2020-05-31 08:48:18
问题 In a Blazor WebAssembly site, suppose I have a class public class State : IState { public bool ShowEasterEggs { get; set; } = false; } And I properly register it in my client's Program.cs: builder.Services.AddSingleton<IState, State>(); And I properly inject this into a component: @inject IState State @if (State.ShowEasterEggs) { <span>EASTER EGGS SHOWN</span> } And in some other component, I enable a change to it: @inject IState State <input type="checkbox" @bind="State.ShowEasterEggs"/>Show

Blazor Client Side Signalr not working when Hosting to IIS

回眸只為那壹抹淺笑 提交于 2020-05-31 05:43:29
问题 Is there any one who can point me in the right direction? When hosting my Blazor Client Side application to IIS the signalr is not working. In visual studio with IIS express it work as expected. I did setup IIS and deployed the application as indicated in the Microsoft documents. There is no console errors and the hub returns status code 200 when hosting in IIS. Thank you in advance 回答1: Websocket support is not enabled by default on IIS. It was introduced in IIS 8, and has to be enabled from

Blazor Client Side Signalr not working when Hosting to IIS

我与影子孤独终老i 提交于 2020-05-31 05:43:13
问题 Is there any one who can point me in the right direction? When hosting my Blazor Client Side application to IIS the signalr is not working. In visual studio with IIS express it work as expected. I did setup IIS and deployed the application as indicated in the Microsoft documents. There is no console errors and the hub returns status code 200 when hosting in IIS. Thank you in advance 回答1: Websocket support is not enabled by default on IIS. It was introduced in IIS 8, and has to be enabled from