Answers for "get current user in asp net core"

C#
0

dotnet core 3.1 get the user that just logged in

private Task<ApplicationUser> GetCurrentUserAsync() => _userManager.GetUserAsync(HttpContext.User);
Posted by: Guest on December-07-2020
0

how to get user browser information in .net core

//  ASP.NET Core Detection with Responsive View for identifying details about client device, browser, engine, platform, & crawler. Responsive middleware for routing base upon request client device detection to specific view.
public class MyCustomMiddleware
{
    private readonly RequestDelegate _next;

    public MyCustomMiddleware(RequestDelegate next)
    {
        _next = next ?? throw new ArgumentNullException(nameof(next));
    }

    public async Task InvokeAsync(HttpContext context, IDetectionService detection)
    {
        if(detection.Device.Type == Device.Mobile)
            context.Response.WriteAsync("You are Mobile!");

        await _next(context);
    }
}
Posted by: Guest on December-10-2021

Code answers related to "get current user in asp net core"

C# Answers by Framework

Browse Popular Code Answers by Language