blazor-server-side

How to download in-memory file from Blazor server-side

独自空忆成欢 提交于 2021-01-21 08:35:13
问题 Is there a way to download a file, generated dynamically in memory in Blazor Server Side without need to store it on a filesystem? 回答1: The solution was in adding Web Api contoller into Blazor server side app. Add Controllers/DownloadController.cs controller to the root of Blazor app: [ApiController, Route("api/[controller]")] public class DownloadController : ControllerBase { [HttpGet, Route("{name}")] public ActionResult Get(string name) { var buffer = Encoding.UTF8.GetBytes("Hello! Content

How do I update multiple users on Blazor Server-Side?

只愿长相守 提交于 2021-01-20 20:32:13
问题 Suppose I want a UI where users in a group have a synchronized view. Imagine a group-chat application, where everyone in the group should see the exact same messages. When a user posts a message to the group, the entire group needs to receive it. With JS, I might use SignalR Groups, and have the front-end generate a SignalR event with a message is posted. The server-side hub would then send that message out to the group. On Server-Side Blazor, since all the users' states are already on the

How to use both Blazor client and server in same web

喜你入骨 提交于 2021-01-20 08:14:39
问题 I'm learning about the Blazor , and see benefit of 2 types client-side and server-side . I want to use both on the same web e.g. one path is a client-side WebAssembly app, another path is a server-side that run code in server. I have seen Blazor Full-Stack template (not quite understand) but it missing from latest templates package. Did they remove it on purpose? (only 2 left Blazor Server App and Blazor WebAssembly App ) I download templates from this command. dotnet new -i Microsoft

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

Loading data on component load

拟墨画扇 提交于 2021-01-01 08:14:58
问题 One would think this is an easy task. But how do I call a service method on component load without it firing twice? Currently - protected override async Task OnInitializedAsync() { await Initialize(); } private async Task Initialize() { Video = await _VideoService.GetAsync(Id); } Right now this gets called twice, which doens't seem like a good idea to hit the database twice for the same information. I've tried just having this below, but it will throw an error before it even renders everytime

How to use bind-value and bind-value:event on a custom component Blazor

£可爱£侵袭症+ 提交于 2020-12-30 17:09:57
问题 In Blazor, while using inputs, <input bind-value="@InputValue" bind-value:event="oninput"/> This creates a 2 way binding that updates with the oninput event. I would like to recreate this on a custom component with custom events and custom properties. CustomInput.razor <input value="@Value" oninput="@OnInput" /> @code { [Parameter] public string Value { get; set; } [Parameter] public EventCallback<ChangeEventArgs> OnInput { get; set; } } I want to be able to use it this way. <CustomInput bind