ASP.Net Core
Read 5 posts from ASP.Net Core
Posts
Getting logged in user ID in non-controller class in ASP.Net Core
It’s easy to retrieve the current logged-in user’s information, such as user ID, username, or email, in an ASP.Net Core controller class. However, it can be tricky to access this information in other classes, like the IdentityDbContext class. Here’s an example of how to extract the current user in a non-controller class, specifically in the…
Extract year from database date in C#
In one of my projects, I was needed to extract a year from a database query and use it at a later stage in the program. I had to declare a nullable Datetime variable and assign the value from the database in a loop. Database query result need to assign in expiryDate variable The date…
Hot Reloading in ASP.NET core apps
During the development we often need to make small changes in JavaScript, in CSS or in HTML, to check the change on the browse, we have to compile and run the application in Visual Studio, if app is already running in the browser, then have to stop it and restart the project from VS. I…
Get logged in user name in Core 3.0
To get current logged in user from Identity 2 in .net core 3.0 and 3.1, use the following code. Happy Coding 🙂
ASP.Net Core Seed User and Role
Data seeding for Identity user tables are different. Here is an example code how to seed data without extending the Identity User table. First step to create a class in Data folder Name it “ApplicationDbInitializer.cs”, following code will be in this class. Second step, call above class from Startup.cs file Configure method. Add this line…