asp.net-core-2.1

BadHttpRequestException due to MinRequestBodyDataRate and poor connection

醉酒当歌 提交于 2019-12-06 03:53:59
问题 I have an ASP.NET Core web application that accepts file uploads from authenticated users, along with some error handling to notify me when an exception occurs (Exceptional). My problem is I'm periodically getting alerts of BadHttpRequestException s due to users accessing the application via mobile devices in areas with unreliable coverage. I used to get this with 2.0 too, but until the exception description got updated in 2.1, I never knew it was specifically related to

Entity Framework Core Auto Generated guid

可紊 提交于 2019-12-05 13:40:42
Can some One guide me I want primeryKey of a table as guid having db generated value on insert. [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } but it's giving error The seed entity for entity type 'User' cannot be added because there was no value provided for the required property 'Id'. Here is my actual model classes and DbContxt class: public class BaseModel { [Key] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid Id { get; set; } [Required] [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public DateTime CreatedOn { get; set; }

.Net Core Identity 2 Provider login Cancel leads to unhandled exception

倾然丶 夕夏残阳落幕 提交于 2019-12-05 11:40:44
I've added LinkedIn as a provider. I have implemented the login and register with LinkedIn without any issue. In the use case where the user CANCELS from within the provider Pages (either linkedIn login or cancels the authorization of the app) the identity middleware seems to throw an unhandled exception: An unhandled exception occurred while processing the request. Exception: user_cancelled_login;Description=The user cancelled LinkedIn login Unknown location Exception: An error was encountered while handling the remote login. Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler

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

人走茶凉 提交于 2019-12-05 02:41:44
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 { [PersonalData] public DateTime? LastLoginDateUtc { get; set; } [PersonalData] public DateTime?

SignInManager.PasswordSignInAsync() succeeds, but User.Identity.IsAuthenticated is false

故事扮演 提交于 2019-12-04 16:14:02
I'm new to ASP.Net Core and trying to create an user authentication system. I'm using ASP.Net Core Identity user management. I have the below code for logging in an user. /Areas/Identity/Pages/Account/Login.cshtml.cs public async Task<IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); if (ModelState.IsValid) { // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, set lockoutOnFailure: true var result = await _signInManager.PasswordSignInAsync(Input.Email, Input.Password, Input

.net core - unit of work generic repository pattern

£可爱£侵袭症+ 提交于 2019-12-04 13:17:02
I am Looking to migrate a large project that gathers information about products. The current application uses CSLA as its framework (traditional aspx forms). I am wanting to migrate / develop the application over to .net core 2.1. I have experience of developing in MVC (4+ years) and some recent exposure to .net core. I am wanting to use EF Core to call the existing stored procedures. I am looking at using the Unit of Work Generic repository design pattern. I have used the repository pattern before and found it very useful. As part of the functionality that exists within the current process,

Access DbContext service from background task

佐手、 提交于 2019-12-04 11:30:41
问题 So ASP.NET Core applications have Dependency Injection built right in. And with Entity Framework Core, you can easily get a scoped DbContext instance from a controller action method. But this is all limited to controller actions. If you need to start a long-running background task from an action that will communicate with the view in the browser by other means like WebSocket, then you suddenly have nothing at all. The background task can't use the action's DbContext because that was scoped

Localize `Required` annotation in French implicitly

非 Y 不嫁゛ 提交于 2019-12-04 09:39:00
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 have the messages translated in French, so there is no need for the solution to be bound to the

Inherit from generic class

末鹿安然 提交于 2019-12-04 06:41:35
问题 I have .net core 2.1 project. And my repository classes like below. But because of MyDbContext constructor has parameter, I'm getting error like below. When I remove JwtHelper parametrer, it is working perfectly. But, I need adding JwtHelper in MyDbContext.cs for logging auditings. How can I achieve this? 'MyDbContext' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TContext' in the generic type or method 'UnitOfWork' UnitOfWork.cs public

ASP.NET Core 2.1 - IdentityUser Issue - Cannot create a DbSet for 'IdentityUser' this type is not included in the model for the context

℡╲_俬逩灬. 提交于 2019-12-04 03:17:01
问题 I have upgraded my code from ASP.NET Core 2.0 to Core 2.1. I created a new Core 2.1 project and moved my code into the new project. I have provided samples of my startup and ApplicationDbContext I get the following error when trying to Log In Cannot create a DbSet for 'IdentityUser' because this type is not included in the model for the context. Microsoft.EntityFrameworkCore.Internal.InternalDbSet.get_EntityType() startup.cs //Core 2.1 services.AddDefaultIdentity<IdentityUser>()