.Net Core - amitbhilagude/userfullinks GitHub Wiki
1. Main features
a. Cross platform support Windows, Linux, Mac etc.
b. Faster framework
c. Support of building projects cross platform. Need to have .net core installed and need to use cmd .net CLI to create project or visual studio.
d. Razer Page - Inherited from MVC architecture. Extension .cshtml pattern. C# class inherited from PageModel and IConfiguration to read app settings.
2. Work with Data
a. Create 2 projects(N-tier)
i. Data - to manage static data in dev and DB connect data
ii. Core- to store model
b. Entity framework
i. Nugent package in data for entity core
ii. Nugent package for db specific e.g Sql
c. .net core DB Providers
i. Option for inmemory db for testing
ii. Sql db in image
iii. Local sql db
d. ORM Tools
1. Entity Framework
2. NHibernate
3. Handeling Bad request
4. CDN
5. Concept
a. Entry point with public static main
b. Launch settings to setup environment
i. Express
ii. Live
c. Static Startup Class
d. Calls two runtime methods
i. StartUp.ConfigureServices Used for registering services(components). e.g. Logger Ilogger
1. Dependancy Injection(DI) Framework
a. SingleTone
i. Single instance shared across all components
b. Scope
i. Instance created once per scope, scope will be created every request
c. Transited
i. Every time on request and never shared
e.g. Registering services is done in the ConfigureServices(IServiceCollection) method in your Startup class.
services.Add(new ServiceDescriptor(typeof(IDataService), typeof(DataService), ServiceLifetime.Transient));
services.AddSingleton(<interface>,<class>)
services.AddScoped(<interface>,<class>)
services.AddTransit(<interface>,<class>)
additional extensions .net core services.AddDbContext<DBContextClass>(options=>options.UseSqlServer())
ii. StartUp.Configure
1) Middleware components( Starts with Use..) All requested will be delegated and order is important
1) Exception Error handling
a) UseExceptionHandler
b) UseHsts (adds the Strict-Transport-Security header.)
2) UseHTTPSRedirections
a) Redirect http to the https
3) UseStaticFiles
a) Return Static file
4) UseCookiePolicy
a) Used for GDPR(General data protection requlations)
5) UseAuthetications
a) Authenticate every request
6) UseAuthorisation
a) Authorise every request
7) UseSessionState
8) UseEndPoints
9) UseCors
10) UseKerstel
11) app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
6. HTTP Pipeline (Host)
a. Use - Will not delegate pipeline
b. Map - Branching pipeline based on parameter
c. Run- Delegate Pipeline
7. Memory cacheIMemoryCache Interface
context.Response.Headers.Add("X-Frame-Options", "SAMEORIGIN"); //to protect against 'ClickJacking' attacks
context.Response.Headers.Add("X-XSS-Protection", "1"); //to allow web browser's XSS filter
context.Response.Headers.Add("X-Content-Type-Options", "nosniff"); //to prevent older versions of Internet Explorer and Chrome to perform MIME-sniffing on the response body
context.Response.Headers.Remove("X-Powered-By"); //to remove the hosting server details