blazor

How to render byte array knowing its content-type using Blazor?

青春壹個敷衍的年華 提交于 2021-01-06 04:56:41
问题 The following code corresponds to a Blazor server-side page: @page "/ShowFile/{Id:guid}" //// What to put here to let the browser render the byte array stored on this.Model //// Also how to specify the content type of the response? @code { [Parameter] public Guid Id { get; set; } private byte[] Model { get; set; } protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); //// Gets the byte array of a file based on its identifier. this.Model = await this.GetFile

Blazor send input text back to parent component

╄→尐↘猪︶ㄣ 提交于 2021-01-05 10:12:26
问题 I have child component <input type="text" @bind="@Item" /> <button class="btn btn-primary" onclick="@OnClick">@ButtonText</button> @code { [Parameter] public string ButtonText { get; set; } = "Submit"; [Parameter] public string Item { get; set; } [Parameter] public EventCallback<UIMouseEventArgs> OnClick { get; set; } } With its parent component @using System; <HeadingComponent HeadingText="@HeadingText" /> <ListItemsComponent Items="@ListItems" /> <SubmitButtonComponent Item="@Item"

@onclick=“(() => SomeMethod(parameter))”

时光毁灭记忆、已成空白 提交于 2021-01-05 09:47:12
问题 I am looking into Blazor and I stumbpled on this expression: @onclick="(() => SomeMethod(parameter))" I cannot find/google anywhere what does this (I guess lambda) expression is actually doing. Can anybody explain me please this part: () => and why to use it and where? EDIT: What is the difference between the above and this: @onclick="SomeMethod(parameter)" 回答1: () =>() is basically a lambda function. Imagine you have a function delegate (int foo) { return foo*2}; this can be rewritten as

@onclick=“(() => SomeMethod(parameter))”

落爺英雄遲暮 提交于 2021-01-05 09:44:26
问题 I am looking into Blazor and I stumbpled on this expression: @onclick="(() => SomeMethod(parameter))" I cannot find/google anywhere what does this (I guess lambda) expression is actually doing. Can anybody explain me please this part: () => and why to use it and where? EDIT: What is the difference between the above and this: @onclick="SomeMethod(parameter)" 回答1: () =>() is basically a lambda function. Imagine you have a function delegate (int foo) { return foo*2}; this can be rewritten as

How to combine multiple authentication schemes for different types of clients (user/pass and client/secret) in a Blazor WASM project?

此生再无相见时 提交于 2021-01-05 08:53:38
问题 I have a Blazor WASM project with a Blazor Client and ASP.NET core server. I can authenticate with user/password using the following code: services .AddDefaultIdentity<ApplicationUser>( options => options.SignIn.RequireConfirmedAccount = true) .AddRoles<IdentityRole>() .AddEntityFrameworkStores<ApplicationDbContext>(); services .AddIdentityServer() .AddApiAuthorization<ApplicationUser, ApplicationDbContext>(); services .AddAuthentication() .AddIdentityServerJwt(); services.AddTransient

Using datatables.net with server-side Blazor application

徘徊边缘 提交于 2021-01-05 07:09:53
问题 I'm trying to use datatables.net with my server-side Blazor application and any help would be appreciated. I've tried the code mentioned half-way down https://datatables.net/forums/discussion/56389/datatables-with-blazor, however, the problem I'm having is that certain UI elements such as paging are being replicated when I browse between pages. Below is my _Host.cshtml file @page "/" @namespace MyApplication.Web.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = null; } <

Using datatables.net with server-side Blazor application

冷暖自知 提交于 2021-01-05 07:09:13
问题 I'm trying to use datatables.net with my server-side Blazor application and any help would be appreciated. I've tried the code mentioned half-way down https://datatables.net/forums/discussion/56389/datatables-with-blazor, however, the problem I'm having is that certain UI elements such as paging are being replicated when I browse between pages. Below is my _Host.cshtml file @page "/" @namespace MyApplication.Web.Pages @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @{ Layout = null; } <

Why does Blazor renders component twice

回眸只為那壹抹淺笑 提交于 2021-01-03 03:32:32
问题 I have a simple Blazor component. <div @onclick="HandleClick">Click me</div> @code { public async Task HandleClick() { await Task.Run(()=> System.Threading.Thread.Sleep(1000)); } protected override void OnAfterRender(bool firstRender) { Console.WriteLine("Rendered"); } } When I click on the div "Rendered" is printed to console and after 1 sec again which means that blazor has rendered component twice. I understand that Blazor triggers an automatic re-render of a component as part of

Why does Blazor renders component twice

早过忘川 提交于 2021-01-03 03:30:42
问题 I have a simple Blazor component. <div @onclick="HandleClick">Click me</div> @code { public async Task HandleClick() { await Task.Run(()=> System.Threading.Thread.Sleep(1000)); } protected override void OnAfterRender(bool firstRender) { Console.WriteLine("Rendered"); } } When I click on the div "Rendered" is printed to console and after 1 sec again which means that blazor has rendered component twice. I understand that Blazor triggers an automatic re-render of a component as part of

Why does Blazor renders component twice

随声附和 提交于 2021-01-03 03:30:24
问题 I have a simple Blazor component. <div @onclick="HandleClick">Click me</div> @code { public async Task HandleClick() { await Task.Run(()=> System.Threading.Thread.Sleep(1000)); } protected override void OnAfterRender(bool firstRender) { Console.WriteLine("Rendered"); } } When I click on the div "Rendered" is printed to console and after 1 sec again which means that blazor has rendered component twice. I understand that Blazor triggers an automatic re-render of a component as part of