Skip to main content

Posts

ASp.net core 3.1 identity

It is just an extension to cookie authentication. We get a UI, Tables, helper classes, two factor authentication etc. Even EF and its database constructs. So instead of writing code for all of this we can just use these in built features. Extending Default Identity Classes Add a class that inherits from    public class AppUser : IdentityUser     {         public string Behavior { get; set; }     } Also change the user type in login partial.cs under shared folder Then add migrations and update db using migrations. We can customize further.  services.AddDefaultIdentity<AppUser>(options =>              {                 options.SignIn.RequireConfirmedAccount = true;                 options.Password.RequireDigit = false;           ...

Cookie based Authentication

OpenID Connect is, it solves a different problem, and it's about authentication. So, the idea is that maybe this, this application doesn't need to talk to a back-end service. At least not in the first place. So what, but, but it needs to know who the user is, so. In OpenID Connect you're doing an, a round trip to a so-called authentication server, you type in the password at the authentication server and this returns a token back to the client application that allows it, to validate, your identity. And maybe at some point later, they're using OAuth to get another token to talk to a vacant service, but that, you know, out of two distinct a use case. OpenIDConnect is for Authentication and OAuth for delegating authorization. Purpose Of JWT 1. Contain info about the issuer and claims 2. Contains expiry 3. Signed 4. Client requests a token , issuer issues a token and the resource(API) consumes. The resource has a trust relationship with the token. 5. Are really sma...

ASP NET CORE Facts

 It has an internal web server called Kestral that runs in coordination(collaboration) with the external webserver (assume IIS). The IIS invokes the .net runtime which looks for the main method in the application and executes it. This starts Kestral.  https://app.pluralsight.com/player?course=understanding-aspdotnet-core-2x&author=roland-guijt&name=1e5802e8-d4b6-4784-a8f6-93d1739c88ba&clip=9&mode=live Most versions of classic ASP. NET relied on an assembly in a. NET Framework called System. Web, which was tied to IIS. It is not suitable anymore for today's standards. It is around since classic ASP. NET version 1, and as ASP. NET progressed, stuffed with code to support all kinds of new features. Processing a request using System. Web isn't very efficient anymore for that reason in terms of memory usage and performance. Using the pipeline, youonly plug in what you need, and everything you plug in is in separate assemblies exposed in NuGet. System...

LINQ queries

string[] arr= new string[]{"Anish","Jeeba","Jiya"}; IEnumerable<string> obj= (from item in arr select $"{item} is my name").ToList(); using let  var result = from a in arr let name = a . StartsWith ( 'a' ) where name select a ; let acts as a temporary storage. List < List < SampleList >> sam = new List < List < SampleList >>{ new List < SampleList > { new List<SampleList> { new SampleList{Name="Anish", number=31, Gender="M"}, new SampleList{Name="Anish", number=61, Gender="M"} }, new List<SampleList> { new SampleList{Name="Jeeba", number=12, Gender="F"}, new SampleList{Name="Jiya", number=44, Gender="F"} }, new List<SampleList> ...

MongoDB

Download MongoDB from  https://www.mongodb.com/what-is-mongodb   Install MongoDb nuget package: MongoDB.Driver (Author: rstam.craigwilson) Service  ______________________________________________________________________ public interface IMongoService     {          Employee CreateEmployee(Employee employee);         void Delete(string id);         Employee GetEmployeeById(string id);         List<Employee> GetEmployees();         Employee Update(Employee employee);     } public class MongoService : IMongoService     {         IMongoCollection<Employee> _mongoCollection;         public MongoService(IOptions<EmpDatabaseSettings> options)         {             Options = options;          ...

Events and Delegates

Class with 2 events  public class Worker     {         // Created 2 events         public event EventHandler OnCompleted;         public event EventHandler<WorkerArgs> InBetween;         public void DoWork(int age, string address)         {             for (int i = 0; i < age - 1; i++)             {                 Thread.Sleep(1000);                  // Either this way                 //var del= InBetween as EventHandler<WorkerArgs>;                 //if (del != null) del(this,new WorkerArgs(i,address));                 // Or Directly             ...