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

Az-500 NSG and ASG

Application security groups Application security groups enable you to configure network security as a natural extension of an application's structure, allowing you to group virtual machines and define network security policies based on those groups. You can reuse your security policy at scale without manual maintenance of explicit IP addresses. The platform handles the complexity of explicit IP addresses and multiple rule sets, allowing you to focus on your business logic. To better understand application security groups, consider the following example: In the previous picture,  NIC1  and  NIC2  are members of the  AsgWeb  application security group.  NIC3  is a member of the  AsgLogic  application security group.  NIC4  is a member of the  AsgDb  application security group. Though each network interface in this example is a member of only one network security group, a network interface can be a member of multiple app...

Azure AD Authentication And Authorization

ROLE BASED AUTHORIZATION Step1:   Setup  API. 1. Create an app registration and create an app role. Make sure that the app role is assigned to user and applications. We add it to both user groups and applications as this role can be then assigned to both users and applications. Scopes can only be assigned to apps. Now we can have only users with this role access our application. This app role behind the scenes adds an approles section to the manifest.json. We can directly add it to the manifest file also. Step 2:  Setup an app registration for the UI/ WEB App. . We will grant this app the read role created in the API app (shown above). Go to Azure AD and select the UI app registration. When we register an application 2 elements get created. 1. App registration  2. Enterprise Application -- service principal that get created for the app Adding roles to applications Go to the App registration => API Persmissions => Add a Permission => My API's The My Api's sec...

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