blazor-server-side

how to jwt authentication blazor server without microsoft identity?

本小妞迷上赌 提交于 2020-08-26 10:48:07
问题 i'm using blazor server ( not use webapi, httpclient and ...) and i want to use jwt for authentication Where should I store token? localStorage or cookie? how to send jwt to server all of the request? I had to use AuthenticationStateProvider? I used httpContext but I got an error unless it fit into the cshtml file I also used localstorage inside AuthenticationStateProvider but just got an error also , which one is better? blazor server (one project) or blazor server with webapi?(two project,

Blazor InputText: conditionally rendering an attribute

落花浮王杯 提交于 2020-08-25 04:43:37
问题 Blazor vRC1 I'm looking for a straightforward technique on how to conditionally render an attribute within an <InputText> (or any of the input components for that matter). This used to be simple in MVC Razor, where you'd just write the conditional logic within the @(...) statement. Now, writing @(...) has different meaning in the Razor syntax. For example, I'd like to conditionally output the autofocus HTML attribute for InputText . <InputText @bind-Value="@TextProperty" @(MyModel.isAutoFocus

Blazor InputText: conditionally rendering an attribute

纵然是瞬间 提交于 2020-08-25 04:43:12
问题 Blazor vRC1 I'm looking for a straightforward technique on how to conditionally render an attribute within an <InputText> (or any of the input components for that matter). This used to be simple in MVC Razor, where you'd just write the conditional logic within the @(...) statement. Now, writing @(...) has different meaning in the Razor syntax. For example, I'd like to conditionally output the autofocus HTML attribute for InputText . <InputText @bind-Value="@TextProperty" @(MyModel.isAutoFocus

How to call child component method from parent component with foreach

可紊 提交于 2020-08-10 08:40:10
问题 I've seen examples of how to call a child component's method from a parent component using the @ref attribute, but when I try to use it with a foreach loop, only the last rendered component's method gets called and not all of them. Below are examples of my components. Parent component: <button type="button" class="btn btn-link" @onclick="BtnSyncAll_Click">Run<button> @foreach(var site in Sites) { <Site @ref="SiteView" @Code="@site"></Site> } @code { protected Site SiteView; protected List

Get Current User in a Blazor component

喜夏-厌秋 提交于 2020-08-02 19:12:34
问题 I'm starting a new site with Blazor and Windows Authentication and need to identify the current user viewing the page/component. For a Razor Page, the current user name can be accessed with Context.User.Identity.Name , but that doesn't seem to work in a Blazor component. I've tried injecting HttpContext into the component but the Context is null at runtime. As a bonus, I will eventually want to incorporate this into Startup.cs so I only need to get the username once and can leverage a

Get Current User in a Blazor component

余生颓废 提交于 2020-08-02 19:01:29
问题 I'm starting a new site with Blazor and Windows Authentication and need to identify the current user viewing the page/component. For a Razor Page, the current user name can be accessed with Context.User.Identity.Name , but that doesn't seem to work in a Blazor component. I've tried injecting HttpContext into the component but the Context is null at runtime. As a bonus, I will eventually want to incorporate this into Startup.cs so I only need to get the username once and can leverage a

How to modify the current culture date format in Blazor (server)?

落花浮王杯 提交于 2020-08-02 06:51:07
问题 ASP.NET Core Blazor globalization and localization states: Blazor's @bind functionality performs formats and parses values for display based on the user's current culture. The current culture can be accessed from the System.Globalization.CultureInfo.CurrentCulture property . The statement is true, but the problem is that, the culture has to be set just before it is used (or maybe each time the DOM is refreshed). For demonstration I will use standard blazor counter application. Let's modify

HttpContext is NULL when running web app in IIS

安稳与你 提交于 2020-07-28 20:30:13
问题 I have two application, both running on the same Windows machine. One application is IdentityServer4, and the other is my own web application (Server side Blazor app). Both web apps are build with .NET Core 3.1. When I navigate to my web app, I first get redirected to my IdentityServer4 app. I login, and after that I get redirected back to my web app. The login was successful, because there are no errors in the logs of IdentitServer. Also, I see a certain claim value on my Blazor webpage. I