.net core Flashcards

(30 cards)

1
Q

what is .net core?

A

free and open source platform developed and maintained by microsoft
uses .net standard lib, replaces .net framework
core runs in multiple OS
can modify
integrates with UI frameworks angular vue react
can be hosted in multiple servers
built in dep inj - loosly coupled
supported by multiple IDEs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

advantages of .net core over .net framework?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

what is the default project structure of .net core application?

A

floders
wwwroot - static files like js css images
program.cs - entry point
request go here first
create builder and run
map routes???
startup.cs - config services and request pipeline for the application
set configuration, handle request pipline
appsettings.json - config settings like DB con strings other things???

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

what is the role of program.cs and startup.cs?

A

program.cs - entry point
request go here first
create builder and run
map routes???
startup.cs - config services and request pipeline for the application
set configuration, handle request pipeline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

what is the role of configureservices and configure method?

A

configure services method - optional, called by host before configure method
can add any number of services
addcontrollerswithview() method

configure method specifies how app responds to HTTP request and response
it can add middleware components
request pipelines
user endpoints
not optional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

what is dependency injection in .net core? How do we inject the service dependdency into the controller?

A

creates a loosely coupled design
example many controllers in application
math student created in controllers but then it changes to science student and have to change all of them
instead use IStudent then you get to define implementation in controllers
IStudent passed through constructor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe service lifetimes in .net core?

A

how long instance of class will persist
add singleton - ex: logger
create one instance when service is requested
same instance is shared by all http requests
add scoped - single instance for each request
add transient - instance is not shared
every time a new instance is created for the request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

what is middle ware?

A

a class executed on every request in the application
set up in configure method in startup/program class

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

what is kestrel? what is in process and out process hosting?

A

in process hosting - example IIS hosting and all other uses but can only run in windows not open source
out of process hosting - kestrel used as edge (internet facing) web server
light wieght web server for asp.net app used for hosting
kestrell cross platform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the difference between kestrel and IIS?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is request delegate? what are run use and map methods?

A

handle each http request and used to build request pipeline
run map use are extension methods
use - executes next middle ware method
run - terminates chain, no other middle ware will execute next, end of pipeline
map - executes middleware if path requested by user equalls path provided in the parameter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

what is host in .net core?

A

host configures a server like kestrel or IIS and a request processing pipeline

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

what are the various techniques to save configuration settings in .net core?

A

appsetting.json, azure keyvault, environment variables, comand line args, in memory objects
1st 2 most common

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

how does routing work in .net core?

A

handle incomming http requests for the app, based on the url

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

explain attribute routing in .net core?

A

manipulate behaviour of url by the route attribute

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

describe the request processing pipline for .net core

A

request comes in
1. middleware
2. routing
3. controller intitialization
4. action method executes
5. result of execution
6. data result and/or view rendering
7. response with view result

17
Q

can .net core work with .net 4.x framework?

18
Q

what is meta package?

A

core framework
diagnostics hosting etc

19
Q

how does .net core serve static files?

20
Q

what are the various json files available in .net core?

21
Q

what is .net standard?

A

rule or lib that is compliant with .net

22
Q

what are razor pages in .net core?

A

development model - page centric dev model , supports all features of .net core

23
Q

how is blazor different from razor?

24
Q

how do you use dependency injection work in .net core?

A

inject dependent interface in the configure services method
use @inject directive on the view of razor page

25
what is custom middleware?
use a middleware provided by the .net core framework (static file, routing, cors, authentication, authorization) or custom middleware use methods of the app object you created in program.cs like: app.usestaticfiles() app.userouting() app.useauthorization() app.usecustommiddleware()
26
explain session and state management in .net core
cookies store data on user browser session transfer data between different pages tempdata from controller to view quesry string - limited data, append to url of request
27
how do you handle errors in .net core
set in configure method with app.useexceptionhandler() or app.usedeveloperexeptionpage() if in dev mode the IsDevelopement() method checks the ASPNETCORE_ENVIRONMENT value in launchSettings.json file
28
how do you enable session in .net core? why would you enable session?
set in configure method in program.cs/startup.cs app.usesession() in configure services
29
explain model binding in .net core
data annotation technique set required attribute at top of property maps data in request to controller action method params automatically maps route params to params of action method
30
what is a dto ?
// dto a contract between client and server // shared agreement about how data will be transferred and used