blazor-webassembly

StateHasChanged() vs InvokeAsync(StateHasChanged) in Blazor

拟墨画扇 提交于 2021-02-20 09:32:25
问题 I know that calling the StateHasChanged() method notifies the component that the state has changed and that it should re-render. However, I also see calls to await InvokeAsync(StateHasChanged) or await InvokeAsync(() => StateHasChanged()) in other people's code, but I don't quite understand how it compares to StateHasChanged() and when should one be favored over the other, and why . The only information I could find was this part of the Blazor docs, it says: In the event a component must be

How to get fresh information whether the user is logged in?

删除回忆录丶 提交于 2021-02-11 16:58:40
问题 In this particular case I am only interested in getting info whether the user is logged in or not. Following the answers How to enable/disable elements depending whether the user is logged in or not? I can fetch this information but there is one odd problem. I use Blazor demo app which displays provided "LoginDisplay.razor" component at top, my own page uses following code: @code { protected override async Task OnInitializedAsync() { Console.WriteLine("Init"); var authState = await

How to get fresh information whether the user is logged in?

末鹿安然 提交于 2021-02-11 16:57:54
问题 In this particular case I am only interested in getting info whether the user is logged in or not. Following the answers How to enable/disable elements depending whether the user is logged in or not? I can fetch this information but there is one odd problem. I use Blazor demo app which displays provided "LoginDisplay.razor" component at top, my own page uses following code: @code { protected override async Task OnInitializedAsync() { Console.WriteLine("Init"); var authState = await

how to use usermanager on a blazor page?

五迷三道 提交于 2021-02-11 07:01:29
问题 hello community I have a question how can I use usermanager in a blazor page webassembly ? by injecting this: @inject UserManager<ApplicationUser> UserManager; I get the indication that a usage directive is missing as the class the ApplicationUser class is on the server and the client does not have access to the server. this is my code in blazor page: @page "/index" @inject AuthenticationStateProvider AuthenticationStateProvider @using Microsoft.AspNetCore.Identity; @inject UserManager

how to use usermanager on a blazor page?

夙愿已清 提交于 2021-02-11 07:00:30
问题 hello community I have a question how can I use usermanager in a blazor page webassembly ? by injecting this: @inject UserManager<ApplicationUser> UserManager; I get the indication that a usage directive is missing as the class the ApplicationUser class is on the server and the client does not have access to the server. this is my code in blazor page: @page "/index" @inject AuthenticationStateProvider AuthenticationStateProvider @using Microsoft.AspNetCore.Identity; @inject UserManager

how to persist value in a singleton state container in blazor web assembly on page reload

末鹿安然 提交于 2021-02-10 23:17:36
问题 I practicing and learning blazor web assembly . I'm learning on the ways to communicate between the components. One such way is to use a state container. This works as expected however it does not sustain value on page refresh. Here is my state container class, AppState : public class AppState { public string SomeText { get; set; } } I have registered this as a Singleton instance in Program.cs builder.Services.AddSingleton<AppState>(); with this setup, I'm able to @inject AppState in multiple

how to persist value in a singleton state container in blazor web assembly on page reload

◇◆丶佛笑我妖孽 提交于 2021-02-10 23:17:32
问题 I practicing and learning blazor web assembly . I'm learning on the ways to communicate between the components. One such way is to use a state container. This works as expected however it does not sustain value on page refresh. Here is my state container class, AppState : public class AppState { public string SomeText { get; set; } } I have registered this as a Singleton instance in Program.cs builder.Services.AddSingleton<AppState>(); with this setup, I'm able to @inject AppState in multiple

Blazor's WebApi returns text/html instead of application/json

南楼画角 提交于 2021-02-05 07:21:26
问题 My controller's methods in Blazor's server side WebApi returns an html/text response instead of application/json which leds to The provided ContentType is not supported; the supported types are 'application/json' and the structured syntax suffix 'application/+json'. error. What is the best way to manually set the content type of the response to application/json? My Controller with a Get method [Route("api/[controller]")] [ApiController] public class DeveloperController : ControllerBase {

Blazor WebAssembly with index file configuration logic causing AmbiguousMatchException

点点圈 提交于 2021-01-29 18:36:40
问题 I am creating a Blazor WASM and I need to include logic within the index.html file to load different css/js files and apply various css styles to body tag based on some conditions. However since the root file is static (www/index.html) and the app tag is nested inside the body tag this is not possible. So I followed this link and created an Index.cshtml file (based on the static index file) in the server project and changed the endpoint in the Startup of the server project to

How to debug embedded blazor-webassembly application

北慕城南 提交于 2021-01-29 18:03:56
问题 We host Blazor app as embedded section of a page. Web site itself is a react app. It is convenient for us to use Blazor as dynamic UI engine to draw elements like in a diagram tool. It works well but I would like to know if anyone had a chance to either a. attach a debugger to a running browser and able to set breakpoints and hit them in Visual Studio b. or be able to configure "launch" setting so it would see such app and web assembly as a regular Blazor app and connect to it. on the web