Saturday, November 19, 2022

Registering services in the ConfigureServices method

AddMvcCore
minimum set of services to route and invoke controller. most websites will need more configuration than this.

AddAuthorization
authentication and authorization services.

AddDataAnnotations
mvc data annotations service.

AddCacheTagHelper
mvc cache tag helper service

AddRazorPages
razor pages service includes the razor view engine. commonly used in simple website projects. it calls the following additional methods.
  • AddMvcCore
  • AddAuthorization
  • AddDataAnnotations
  • AddCacheTagHelper
  • AddApiExplorer
  • AddCors
  • AddFormaterMappings
AddViews
support for .cshtml views including default conventions.

AddRazorViewEngine
support for razor view engine including proessing the @symbol.

AddControllerWithViews
controller, views, and pages services. commonly used in ASP.NET Core MVC projects. it calls the following additional methods.
  • AddMvcCore
  • AddAuthorization
  • AddDataAnnotations
  • AddCacheTagHelper
  • AddApiExplorer
  • AddCors
  • AddFormattermappings
  • AddViews
  • AddRazorViewEngine
AddMvc
similar to AddControllerWithViews, but you should only use it for backward compatibility.

AddContext<T>
your DbContext type and its optional DbContextOptions<TContext>

AddCustomContext
a custom extension method we created to make it easier to register the NorthwindContext class for either SQLite or SQL Server based on the project referenced.





No comments:

Post a Comment

methods available in Dapper

  Dapper is a micro ORM library for .NET and .NET Core applications that allows you to execute SQL queries and map the results to objects. D...