logo
down
shadow

No service while customize a new User Context Identity


No service while customize a new User Context Identity

By : user2185666
Date : November 22 2020, 04:01 AM
this one helps. The error message suggests that it is attempting to resolve UserManager, while the user manager should actually use the user entity as its generic type argument. So the type should instead be UserManager.
For the developer-facing services like UserManager, RoleManager or SignInManager you will usually have to use the user type as the type argument, so make sure that you haven’t mixed up the user entity type with the database context type somewhere.
code :


Share : facebook icon twitter icon
Context.User.Identity.Name vs HttpContext.Current.User.Identity.Name

Context.User.Identity.Name vs HttpContext.Current.User.Identity.Name


By : user3211634
Date : March 29 2020, 07:55 AM
like below fixes the issue They are identical. Context has a reference to the current HttpContext which is the same as HttpContext.Current. So, I don't think this is causing the problem that you are having.
Customize @User.Identity.NewMethodHere() to return a user first and last name, using ef code first and asp.net mvc

Customize @User.Identity.NewMethodHere() to return a user first and last name, using ef code first and asp.net mvc


By : Lordan
Date : March 29 2020, 07:55 AM
seems to work fine to wdosanjos for pointing me to extenstion method. After reading the link and googling some more I came up with this:
code :
public static class IdentityApplicationUserExtension
{
    public static User GetApplicationUser(this IIdentity identity)
    {
        var manager = new UserManager<User>(new UserStore<User>(new MyDbContext()));
        return manager.FindById<User>(identity.GetUserId());
    }
}
 @User.Identity.GetApplicationUser().AnyColumnFieldHere
Why Context.User.Identity.Name is null in Windows Form Hub Context?

Why Context.User.Identity.Name is null in Windows Form Hub Context?


By : ram
Date : March 29 2020, 07:55 AM
To fix the issue you can do It looks like you are trying to get the username when connecting to the hub. I solved a similar issue by passing the username from my client. It also sounds like you are making use of the SignalR .NET client. Give this a try
Client
code :
Connection = new HubConnection("http://.../", new Dictionary<string, string>
{
    { "UserName", WindowsIdentity.GetCurrent().Name }
});
public override Task OnConnected()
{
    string userName = Context.QueryString["UserName"]
}
Asp.Net Core Identity 2.2 and Identity Server 4, Changing User Id type results in an error in the db context

Asp.Net Core Identity 2.2 and Identity Server 4, Changing User Id type results in an error in the db context


By : silentblood
Date : March 29 2020, 07:55 AM
Hope that helps After got this code sample to run successfully, I tried to change the Identity User Id type to Guid: , You can try below steps :
code :
public class AppUser : IdentityUser<Guid>
{
    // Add additional profile data for application users by adding properties to this class
    public string Name { get; set; }        
}
public class AppIdentityDbContext : IdentityDbContext<AppUser, IdentityRole<Guid>, Guid>
{
        ...
}
services.AddIdentity<AppUser, IdentityRole<Guid>>()
    .AddEntityFrameworkStores<AppIdentityDbContext>()
    .AddDefaultTokenProviders();
ASP.NET Core 3: Cannot resolve scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Alpha.Models.Identity.User]'

ASP.NET Core 3: Cannot resolve scoped service 'Microsoft.AspNetCore.Identity.UserManager`1[Alpha.Models.Identity.User]'


By : Stegow
Date : March 29 2020, 07:55 AM
To fix this issue From the screenshot you've included, it shows that you've got the following line in Startup.Configure:
code :
ApplicationDbContext.CreateAdminAccount(app.ApplicationServices, Configuration)
    .Wait();
public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider)
{
    ApplicationDbContext.CreateAdminAccount(serviceProvider, Configuration)
        .Wait();
}
public class Program
{
    public static async Task Main(string[] args)
    {
        var host = CreateHostBuilder(args).Build();

        using (var scope = host.Services.CreateScope())
        {
            var serviceProvider = scope.ServiceProvider;
            var config = serviceProvider.GetRequiredService<IConfiguration>();

            await ApplicationDbContext.CreateAdminAccount(serviceProvider, config);
        }

        await host.RunAsync();
    }

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        // ...
}
Related Posts Related Posts :
  • C# Linq Find duplicates with multiple group by
  • How to call control on a Panel that is inside usercontrol
  • c# ReadAsJsonAsync in framework 4.5
  • Inner join two table variables and return an output cursor from an anonymous plsql block in a c# application
  • Notify consumers when all tasks have completed without blocking the thread
  • Replace "\\" with "\" in a path
  • CSS Not formatting inside repeater
  • CheckedListBox filter with a TextBox
  • How to not evaluate the third part of a ternary operator unless necessary
  • How to avoid going into cache block in c# and return to loop iteration?
  • How do I add just one element to an array when I call a method c#
  • Image.RotateFlip doesn't seem to rotate the Bitmap
  • swagger add document and operation for a generic controller
  • Avoid a random selection of the same point to imitate "human-like" behavior
  • Howto use PostgreSQL table names without double quotes in C# and Npgsql
  • .NET Core Entity Framework InvalidOperationException
  • Database Context save if valid
  • How do I flatten an array of arrays?
  • Serialize Property as Xml Attribute in new Element
  • How to make a flash-animation with a row of pictureboxes?
  • Add ClientId to the "Authorized API Clients"
  • Sending data between 2 forms
  • How do you get POSTed value from dynamically populated dropdownlist without the use of UpdatePanel?
  • C# Inconsistent accessibility: return type is less accessible than method
  • MVC Razor how to get option value from form and set viewmodel property to selected value
  • Automapper error after updating a record with POCO classes, Unity and EF6
  • Xamarin Forms Change NavBar background image on Specific pages
  • How to recognize element in which item in the gridview
  • Loading DataGridView only once based on listbox item selected
  • WCF Service not hitting from postman over https
  • Export telerik RadGrid to PDF
  • Why won't C# decimal ToString request culture AND currency?
  • Using constant string in all include pages
  • Write Roslyn analyzer by Rider
  • What is the difference between a dSYM folder and an mSYM folder?
  • replace inheritance with generic extension method
  • C# XAML binding
  • Span<T> and streams in .NET framework
  • Using phyton.exe in .net c# controller:
  • How to get distinct values from set of rows matching condition
  • MySqlParameter type conflict when using Entity Framework with Pomelo
  • Why there is black color shed on the upper side and left side on textbox border in ASP.Net
  • Autofac resolving named service incorrectly
  • Cumulative sum of array items
  • Bot connector returns Forbidden (403) with Microsoft.Bot.Connector.ErrorResponseException
  • What is the right way to show only group by column in datatable
  • C# Trying to get a list of questions from one class into my Main() class loop
  • In database AutoIncrease column. What if value reached maximum value
  • How to access controls of dynamically added user controls in a panel in C#?
  • Dynamic DataTable Group by and Aggregate functions
  • Binding selected ListBox Image somewhere else in MainWindow
  • Apply Ninject to work with "child viewmodels" in my C# WPF application
  • Create System.Net.WebProxy from string including credentials
  • error in implementing Ignite.net with persistence
  • WPF Button click not properly comparing variable to array value
  • Create custom iterable Dictionary with one generic type
  • How do I use ExecuteScalar with a stored Procedure?
  • HttpPostedFileBase always returns null when posting it with Model but working perfact without model
  • WIndows 10 MIDL.exe
  • Different versions of ODAC causing error in C# application (local Vs Server)
  • shadow
    Privacy Policy - Terms - Contact Us © bighow.org