blazor

How to use the HttpContext object in server-side Blazor to retrieve information about the user, user agent

三世轮回 提交于 2020-01-11 13:19:09
问题 IP Address, and such like. Very often when users ask how to do it in Server Blazor app, they are either told that it is not possible, or sometimes offered partial solutions employing JSInterop. But can it be done without resorting to JSInterop ? Here's the answer... 回答1: The fiction that the HttpContext object can't be used with Blazor Server App, has been long propagated in stackoverflow, and it is high time to pension it off. It is true that the HttpContext is not available when a WebSocket

How to refresh a blazor sub/child component within a main/parent component?

不打扰是莪最后的温柔 提交于 2020-01-11 12:43:33
问题 You have a main component and inside the main component you have many sub-components You want to refresh a single subcomponent, rather than the entire screen of the main component, is this possible? 来源: https://stackoverflow.com/questions/59226890/how-to-refresh-a-blazor-sub-child-component-within-a-main-parent-component

How Blazor Framework get notifed when the property value gets changed

故事扮演 提交于 2020-01-11 05:21:05
问题 When we have a HTML code like below. <h1>@Title</h1> and C# like below public string Title { get; set; } Think I have executed a code like below Title = "New title updated in the runtime"; Then we see that the view has chenged with the new value. How the renderer knows that the property value has changes. Is there anything like INotifyProperyChange is implemented. How the HTML knows that this is the time to update the content. I just want to know how the internals of the Blazor Framework are

Cannot access a disposed object in Blazor Server 3.0

丶灬走出姿态 提交于 2020-01-07 08:24:33
问题 I got a Blazor page with following form submit button <button type="submit" class="btn btn-primary" @onclick="@(async()=> await OnCreateItem())">Create </button> Which calls protected async Task OnCreateItem() { try { var result = await dbMgr.CreateAsync(item); } catch (Exception ex) { Throws ==> Cannot access a disposed object. A common cause of this error is disposing a context that was resolved from dependency injection and then later trying to use the same context instance elsewhere in

Upload progress using HttpClient in Blazor Wasm

扶醉桌前 提交于 2020-01-06 08:16:51
问题 I'm trying to get file upload progress inside a blazor web assembly app. var handler = new ProgressMessageHandler(); handler.InnerHandler = new WebAssemblyHttpMessageHandler(); handler.HttpSendProgress += (object sender, HttpProgressEventArgs e) => { Console.WriteLine("bytes transfered= " + e.BytesTransferred.ToString()); Console.WriteLine("total bytes= " + e.TotalBytes.ToString()); Console.WriteLine("progress percentage= " + e.ProgressPercentage.ToString()); }; var http = new HttpClient

Visual Studio 2017 Blazor Project Templates Missing

六月ゝ 毕业季﹏ 提交于 2020-01-06 06:43:22
问题 I'm exploring building a Blazor SPA app for a test project I'm working on using Visual Studio 2017 (15.9.4). I have installed .NET Core 2.2.1 and the Blazor Language Services extension but when I open Visual Studio to create a new project, no Blazor template is shown. I was able to create a project using the CLI but when I open the project in Visual Studio it gives several errors inside even though the project runs. There are also no Blazor page templates available when I try to New Item.

How to set consent cookie in Blazor Server

拈花ヽ惹草 提交于 2020-01-06 04:30:09
问题 I have a Blazor 3.1 App with Identity where I want to implement a cookie consent banner. In classic ASP .NET Core, there is a nice template for a cookie consent banner. @using Microsoft.AspNetCore.Http.Features @{ var consentFeature = Context.Features.Get<ITrackingConsentFeature>(); var showBanner = !consentFeature?.CanTrack ?? false; var cookieString = consentFeature?.CreateConsentCookie(); } @if (showBanner) { <div class="container"> <div id="cookieConsent" class="alert alert-info alert

Can Blazor create wasm modules without any UI references or code?

人盡茶涼 提交于 2020-01-06 02:48:06
问题 Looking at the Blazor documentation I get the impression that it is meant to be used to develop client side browser applications. A subset of this should be creating WASM output in the same way Rust does, but I cannot see any documentation that explains how can I create standalone WASM output which then can be called from JavaScript or if I can do it at all. So is it possible to use Blazor or Belero (its F# cousin, based on Blazor) to create wasm libraries and not full applications? 回答1: A

Dynamic Text Field Creation with Values in Blazor App

点点圈 提交于 2020-01-05 07:23:52
问题 Expected Output Output @page "/" @using UDemo.Data @for (int i = count; i >= 1; i--) { <div class="row"> <input type="text" @bind-value="@text_val" /> <p>@i</p><p>@count</p> </div> } <div class="row"> <button @onclick=@(() => Increment())>Add User</button> </div> @code { private List<string> listItems = new List<string>(); private string newItem; public string select_val; public string text_val; public int count = 1; public void Increment() { count = count + 1; } } In this Code am trying to

Dynamic method parameter using Blazor Binding [duplicate]

和自甴很熟 提交于 2020-01-05 04:08:09
问题 This question already has answers here : Getting ArgumentOutOfRangeException using for loop in Blazor component (2 answers) Closed 10 days ago . I'm trying to make a paging component by using Blazor. Navigate First , Last , Previous and Next are already working. The problem is: I want the user to be able to click on a page number and the NavigateToPage action to be executed by passing the page number. Here's my attempt: <div class="col-12 col-md-6 col-lg-3 offset-lg-6 text-right"> <nav aria