Skip to main content

ASP NET CORE Facts


  1.  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. Web relied on IIS, and IIS is tied to Windows. That'sthe reason you can't run classic ASP. NET apps on other web servers than IIS, and only on Windows. Now that this limitation is lifted, in ASP. NET Core you can runapps on many external web servers for many operating systems. Keep in mind that there are actually two web servers, one web server that I call the external webserver. This is a full-blown production-ready web server like IIS, Apache, or NGNIX on Linux, for example. There's also an internal web server, part of and hosted by your app. Requests to the external web server are proxied to the internal web server, and vice versa. Like the external web server, you're also not tied to using a specific internal web server. The most obvious choice is Kestrel because it's very fast, it is implemented cross-platform, and it has first-class support in ASP. NET Core. Kestrel is a lightweight web server; it doesn't have much more features than actually executing a request. That's why you need an external web server in production scenarios, which you can configure security, configure caching and compression, set up mappings to the right app depending on the URL, and many more things.
  1. Calling next element in the pipeline

The use method has a parameter next which helps the execution to continue as the execution stops if the next element in the pipeline is not called manually. This is the case when we add our own elements to the pipeline. Everything before the await happens during the incoming request processing and after all the pipeline elements have been processed everything after the next() will be executed.


Unified Controllers


Earlier ASP. NET versions had a clear distinction between MVC, the framework for web user interfaces, and web API, the framework for REST web services, also known as APIs, that expose data only. Web API was created following the exact same model MVC uses. It, in fact, also uses the MVC pattern used in types that are in most cases named exactly like the types used in MVC. One of the reasons to build web API completely separate from MVC, even though it matches one to one, was because MVC relied on the System. Web assembly, which is tied to IIS and Windows. Microsoft wanted to untie a web API from System. Web, which among other benefits gave web API applications the ability to be self-hosted. Now that all of ASP. NET Core doesn't use System. Web anymore, it doesn't really make sense anymore to have two sets of types that do almost the same thing. In ASP. NET Core there is just one set of types to support the functionality of MVC and a web API. And because everything is unified now, having multiple names for the same thing also doesn't make sense, so the name web API has been dropped. The combined functionality of MVC and web API is now just called ASP. NET Core MVC.



Comments

Popular posts from this blog

App Role assignment to service principal --

 Using Ms Graph Rest API's Permissions One of the following permissions is required to call this API. To learn more, including how to choose permissions, see  Permissions . Permission type Permissions (from least to most privileged) Delegated (work or school account) AppRoleAssignment.ReadWrite.All and Application.Read.All, AppRoleAssignment.ReadWrite.All and Directory.Read.All, Application.ReadWrite.All, Directory.ReadWrite.All Delegated (personal Microsoft account) Not supported. Application AppRoleAssignment.ReadWrite.All and Application.Read.All, AppRoleAssignment.ReadWrite.All and Directory.Read.All, Application.ReadWrite.All, Directory.ReadWrite.All Create 2 app registrations. App role owner will contain the app role that will be assigned to a service principal. The  reader role in approleowner will be added to the approlesubscriber Setup postman to use the Oauth auth flow to get a token for MS Graph. ClientId:   Application (client) ID for approlesubscrib...

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;           ...

Get user groups

 string[] scopes = new string[] { "https://graph.microsoft.com/.default" };             string clientId = "";             string tenantId = "";             string secret = "";                        var options = new TokenCredentialOptions             {                 AuthorityHost = AzureAuthorityHosts.AzurePublicCloud             };             // https://learn.microsoft.com/dotnet/api/azure.identity.clientsecretcredential             try             {                 var clientSecretCredential = new ClientSecretCredential(                        ...