asp.net-core

ASP.NET Core 3.1 / Identity session never expires. How can I get it to expire on sliding expiration?

一笑奈何 提交于 2021-02-10 12:57:41
问题 A security check of my website showed that sessions (i.e. login) never expire. I've tested myself and I find the same - I opened up the site on localhost this morning and I'm still signed in from yesterday. I always assumed it would expire after 20 minutes like it would in .NET Framework apps. I'm using the ASP.NET Core Identity scaffolding with minimal changes other than implementing two factor authentication. In my Startup.cs I have the following code to add session support: services

ASP.NET Core 3.1 / Identity session never expires. How can I get it to expire on sliding expiration?

落花浮王杯 提交于 2021-02-10 12:57:17
问题 A security check of my website showed that sessions (i.e. login) never expire. I've tested myself and I find the same - I opened up the site on localhost this morning and I'm still signed in from yesterday. I always assumed it would expire after 20 minutes like it would in .NET Framework apps. I'm using the ASP.NET Core Identity scaffolding with minimal changes other than implementing two factor authentication. In my Startup.cs I have the following code to add session support: services

ASP.NET Core 3.1 / Identity session never expires. How can I get it to expire on sliding expiration?

荒凉一梦 提交于 2021-02-10 12:57:15
问题 A security check of my website showed that sessions (i.e. login) never expire. I've tested myself and I find the same - I opened up the site on localhost this morning and I'm still signed in from yesterday. I always assumed it would expire after 20 minutes like it would in .NET Framework apps. I'm using the ASP.NET Core Identity scaffolding with minimal changes other than implementing two factor authentication. In my Startup.cs I have the following code to add session support: services

How to check if a section in MVC Core configuration file exist?

丶灬走出姿态 提交于 2021-02-10 12:49:08
问题 How can I check if a specific section in loaded ASP.NET Core configuration file exist? I have a JSON configuration file that I load it in Startup class via ConfigurationBuilder.AddJsonFile method. This JSON file is an array with this layout: { "Url": "", "Regex": [ "", "" ], "Keys": { "Title": "", "Description": "", "Keywords": [ "" ] } } But some of them doesn't have Keys . I tried to check return type of section.GetSection("Keys") against null , But it doesn't return null even if Keys

How to check if a section in MVC Core configuration file exist?

我只是一个虾纸丫 提交于 2021-02-10 12:49:07
问题 How can I check if a specific section in loaded ASP.NET Core configuration file exist? I have a JSON configuration file that I load it in Startup class via ConfigurationBuilder.AddJsonFile method. This JSON file is an array with this layout: { "Url": "", "Regex": [ "", "" ], "Keys": { "Title": "", "Description": "", "Keywords": [ "" ] } } But some of them doesn't have Keys . I tried to check return type of section.GetSection("Keys") against null , But it doesn't return null even if Keys

RedirectToAction starts new session

≡放荡痞女 提交于 2021-02-10 07:56:21
问题 I have a controller which logins in my user. Assuming its an existing user and the password is correct i check if they have 2fa enabled. AccountControler login method public async Task<IActionResult> Login(LoginViewModel model, string returnUrl = null) { ViewData["ReturnUrl"] = returnUrl; 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

How to use web sockets in C# .NET Core 3.1?

心不动则不痛 提交于 2021-02-10 07:49:25
问题 I am trying to implement live notifications in my web application. Only the users which are administrators in my web app should see the notifications. So I setup the web socket in my startup.cs file which I think is not the right way Startup.cs var webSocketOptions = new WebSocketOptions() { KeepAliveInterval = TimeSpan.FromSeconds(120), ReceiveBufferSize = 4 * 1024 }; app.UseWebSockets(webSocketOptions); app.Use(async (context, next) => { if (context.Request.Path == "/ws") { if (context

Routing between ASP.NET Core web application and Razor Class Library projects

感情迁移 提交于 2021-02-10 06:48:13
问题 I created a project ASP.NET Core 3.0 MVC and it works fine. In the same solution, I added 3 (or more) projects "Razor Class Library". Each such project has a controller. How do I configure routing so that I can access the controller methods of these projects? My solution looks like this: MyProject.Shop (Razor Class Library) |_ Controllers |_ HomeController.cs MyProject.Books (Razor Class Library) |_ Controllers |_ HomeController.cs MyProject.Web (main ASP.NET Core 3.0 MVC project) |_

Why is EF Core Update failing to update a modified column

只愿长相守 提交于 2021-02-10 06:42:06
问题 Im using EF Core and Im trying to update a column/property of an entity. The column has a foreign key constraint...is nullable and is an int. The same table/entity has three or four other columns/properties the same datatype also foreign key constrained...and nullable When I update the values of any of these column using the Update command...It works perfectly fine...EXCEPT for one column. When I try to update that one column and i process the update it will save all changes...but that column

EF Core model building conventions

风流意气都作罢 提交于 2021-02-10 06:27:09
问题 In EF6 it was possible to define conventions based on property types during model building, like so... public interface IEntity { Guid Id { get; } } public class MyEntity : IEntity { public Guid Id { get; set; } } public class MyDbContext : DbContext { public override void OnModelCreating(DbModelBuilder builder) { builder .Properties<Guid>() .Where(x => x.Name == nameof(IEntity.Id) .Configure(a=>a.HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)); } } This approach could also be