Skip to content

Instantly share code, notes, and snippets.

@steamonimo
Last active April 28, 2021 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save steamonimo/4445f8f047f0e65c8a5a0ab62bb9cbd4 to your computer and use it in GitHub Desktop.
Save steamonimo/4445f8f047f0e65c8a5a0ab62bb9cbd4 to your computer and use it in GitHub Desktop.

Blazor: c# development

input field: update bound variable while typing

razor

@bind-Value="@variable"  @oninput="@(args => OnInput(args.Value.ToString()))"

code

public string variable {get; set;}

void OnInput(string value)
{
    variable = value;
}

identity management: check if the user is authenticated

code

var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
var user = authState.User;

if (user.Identity.IsAuthenticated)
{
    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment