DotNet Core

In an ASP.NET Core application, middleware acts as a software component that sits within the request pipeline, handling incoming requests and outgoing responses by performing specific tasks like logging, authentication, authorization, error handling, or serving static files, allowing developers to modularly add functionality to their application as each request passes through a chain of middleware components, executing them in a defined order. 

Key points about middleware:

Example of middleware usage:


In .NET Core, cross-cutting concerns like logging, error handling, security, and caching are typically managed using a combination of middleware, dependency injection, and Aspect-Oriented Programming (AOP), allowing you to modularize these concerns and apply them consistently across your application without cluttering your core business logic within individual classes.  

In .NET Core, "app.Use" refers to a method used to add middleware components to the HTTP request pipeline within an ASP.NET Core application 

//for delete item

<input asp-for="CategoryId" hidden />


https://github.com/CodeSeven/toastr

<footer class="fixed-bottom site-footer text-muted  bg-dark ">

       <div class="container text-center">

            &copy; 2022 - WebAppCore6 - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>

        </div>

    </footer>

builder.Services.AddRazorPages().AddRazorRuntimeCompilation();


public class ApplicationDbContext : DbContext

    {

        public ApplicationDbContext(DbContextOptions<ApplicationDbContext>  options ) : base(options)

     {

}


        public DbSet<Category>? Categories { get; set; }

       

    }

public class ApplicationDbContext : IdentityDbContext

    {

        public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)

            : base(options)

        {

        }



Linq Join example


var query = (from prod in objProductList

                         join catg in lstCategory

                         on prod.CategoryId equals catg.CategoryId

                         join covr in lstCoverType

                         on prod.CoverTypeId equals covr.CoverTypeId

                         select new Product

                         {

                             ProductId = prod.ProductId,

                             Title = prod.Title,

                             Description = prod.Description,

                             ISBN = prod.ISBN,

                             Author = prod.Author,

                             Price = prod.Price,

                             ImageURL = prod.ImageURL,

                             CategoryName = catg.Name,

                             CoverTypeName = covr.Name


                         }).ToList();


https://www.c-sharpcorner.com/article/differences-between-scoped-transient-and-singleton-service/