asp.net-core-2.1

Store does not implement IUserRoleStore<TUser> ASP.NET Core 2.1 Identity

空扰寡人 提交于 2019-12-22 04:06:09
问题 I'm using ASP.NET Core 2.1 Identity. I've overridden IdentityUser because I need to add some additional properties on the user. In Startup.cs services.AddDefaultIdentity<PortalUser>().AddEntityFrameworkStores<ApplicationDbContext>(); ApplicationDbContext.cs public partial class ApplicationDbContext : IdentityDbContext<PortalUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } } PortalUser class public class PortalUser : IdentityUser {

Store does not implement IUserRoleStore<TUser> ASP.NET Core 2.1 Identity

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-22 04:05:23
问题 I'm using ASP.NET Core 2.1 Identity. I've overridden IdentityUser because I need to add some additional properties on the user. In Startup.cs services.AddDefaultIdentity<PortalUser>().AddEntityFrameworkStores<ApplicationDbContext>(); ApplicationDbContext.cs public partial class ApplicationDbContext : IdentityDbContext<PortalUser> { public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { } } PortalUser class public class PortalUser : IdentityUser {

Type or Namespace Name “AspNetCore” does not exist error when publishing to Azure

寵の児 提交于 2019-12-22 03:18:10
问题 In Visual Studio 2017, I build my ASP.NET Core 2.1 app with no errors but when I try to publish it to Azure, I get errors that indicate I'm missing a reference to an assembly -- see below: But I'm not missing a reference and where these errors point, the reference is there with no errors whatsoever. More importantly, this is happening ONLY IF I target a runtime other than "Portable" in my publish profile. If I select "Portable" for target runtime and leave it at "Framework dependent" in

Creating generic DbContext Factory in Entity Framework

别等时光非礼了梦想. 提交于 2019-12-22 00:39:04
问题 I'm using .Net Core 2.1. I'm using more than one DbContext . I'm creating a DbContextFactory for every context. But, I want to do this in a generic way. I want to create only one DbContextFactory . How can I achieve this? MyDbContextFactory.cs public interface IDbContextFactory<TContext> where TContext : DbContext { DbContext Create(); } public class MyDbContextFactory : IDbContextFactory<MyDbContext> { public IJwtHelper JwtHelper { get; set; } public MyDbContextCreate() { return new

Localize `Required` annotation in French implicitly

穿精又带淫゛_ 提交于 2019-12-21 19:27:41
问题 TLDR; How to get the behaviour of [Required(ErrorMessage = "Le champ {0} est obligatoire")] while only writing [Required] As I understand it the documentation does not provide a way to implicitly localize a given set of DataAnnotations. I would like to have the error messages for annotations such as Required and StringLength be over-rideable without touching others such as Display and without the need to explicitly specify the translation using the ErrorMessage attribute. note: I only need to

Using AspNetUserTokens table to store refresh token in ASP.NET Core Web Api

那年仲夏 提交于 2019-12-21 07:38:48
问题 I'm working with ASP.NET Core Web API application. I'm trying to implement Jwt Token Based Authentication on top of ASP.NET Identity( built in with database tables). I have implemented all scenarios like register user, login etc but now trying to implement refresh token flow( where access token get expired, client need to get replaced access token using refresh token) . I have seen people are creating new table (refreshToken) to store refresh token so it can be validated with access token and

Using AspNetUserTokens table to store refresh token in ASP.NET Core Web Api

不打扰是莪最后的温柔 提交于 2019-12-21 07:38:42
问题 I'm working with ASP.NET Core Web API application. I'm trying to implement Jwt Token Based Authentication on top of ASP.NET Identity( built in with database tables). I have implemented all scenarios like register user, login etc but now trying to implement refresh token flow( where access token get expired, client need to get replaced access token using refresh token) . I have seen people are creating new table (refreshToken) to store refresh token so it can be validated with access token and

HttpClient with .Net Core 2.1 hangs

本秂侑毒 提交于 2019-12-21 07:36:50
问题 Given the following .Net Core 2.1 Console App... using System; using System.Diagnostics; using System.Net.Http; using System.Net.Http.Headers; namespace TestHttpClient { class Program { static void Main(string[] args) { try { using (var httpClient = new HttpClient()) { httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); string url = "https://jsonplaceholder.typicode.com/posts/1"; var response = httpClient.GetAsync(url).Result; string

How do I get a reference to an IHostedService via Dependency Injection in ASP.NET Core?

荒凉一梦 提交于 2019-12-21 03:54:12
问题 Details I have attempted to create a background processing structure using the recommended IHostedService interface in ASP.NET 2.1. I register the services as follows: services.AddSingleton<AbstractProcessQueue<AbstractImportProcess>>(); services.AddHostedService<AbstractBackgroundProcessService<AbstractImportProcess>>(); services.AddSignalR(); The AbstractProcessQueue is just a wrapper around a BlockingCollection of processes that can be enqueued and dequeued. The

How to disable precompiled views in net core 2.1 for debugging?

旧城冷巷雨未停 提交于 2019-12-21 03:34:10
问题 Yesterday I updated to net core 2.1. Now if I am debugging, the views getting precompiled, which ofcourse takes a long time during startup... Is it possible to fall back to the previous behavior, where the Views are compiled just in time, if it is needed? I have no reference related to precompilation in my csproj. Is it something that comes from the meta package? <ItemGroup> <PackageReference Include="JetBrains.Annotations" Version="11.1.0" /> <PackageReference Include="Microsoft.AspNetCore