Services Flashcards

(25 cards)

1
Q

Core vs Framework

A

Framework is legacy implementation of .NET which was could run only on windows, hosted on IIS. Core is a complete rewrite implementation with modularity that can run on cross platforms using built in Kestrel which makes the apps faster. Core has built in way to manage configuration, dependency Injection middlewares centrally while in framework it was scattered and manually done

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

Explain .NET Core Architecture

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

Kestrel vs IIS

A

Kestrel is default built in to .net core which is a lightweight fast web server that can run on cross platforms. But not production grade because is lacks lot of platform specific features.
IIS is a complete web server with features like app pool recycle, port management, ssl certificate. It is used as reverse proxy in production in front of Kestrel to add in these features and Kestrel only does traffic management

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

Web.config vs Appsettings.json

A

Web config was in framework written in XML and inconvenient to handle for different environments. The configuration usage in code was scattered with hardcoding of keys. Application needed to be restart to apply changes to configuration

Appsettings is a better readable json in core which is picked by automatically by configuration service giving centralised management , DI support, validation, hot reload and change tracking

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

Launchsettings vs Appsettings

A

Launchsettings is a tooling file that is used by CLI to know how to start the app. It is not used for publishing the apps. It can create profiles with application url, whether to launch browser, ports, add environment Variables which is ultimately read by configuration service. It is found in properties folder.

Appsettings is the app config provider that configuration service reads and is used for publishing the app.

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

Does configuration service read launch settings

A

No. However launch settings can add environment Variables in locally run machine which the configuration service reads for localhost site.

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

What are launch profiles

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

How does core read config values

A

Configuration service reads multiple default and custom providers to merge into key value pairs. The later provider values override the earlier. It gives centralised way to manage with DI support and hot reload. We can mock and test.
With options pattern we get strongly typed, validation, change tracking, per request values

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

How to access values from configuration

A

Ad hoc way using builder.Configuration or bind it to classes making it strongly typed. Recommended way is to use options pattern

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

Ad hoc vs Binding config

A

Ad hoc is best for quick one off for simple primitive values and binding is good for reusing with complex nested sections like dictionary, list with strong typing.

Ad hoc converts the values and can throw exceptions while binding creates instances with default or null and then overwrite by extracting values, so can cause silent failures.

Ad hoc is hard to test because they are scattered but binding makes mock testing easier

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

What is options pattern

A

Pattern built in to read and manage grouped configuration settings with DI Support. It provides centralized configuration, strongly typed safe access using validations, hot reload and change tracking

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

IOptions, IOptionsSnapshot, IOptionsMonitor

A

IOptions is used for singleton snapshot of config at app start for stable and static values. It doesn’t support hot reload. Use it for api key, title, page secret, connection strings

IOptionsSnapshot is used for per request values. It is scoped + named options and refreshes at start of request. Use it for fresh request discount prices

IOptionsMonitor is used for values that can change manually or dynamically. It is singleton and supports hot reload + change tracking. Use it for disabling product category, flash sale discount, feature flags, alerts, cache levels, log levels

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

Why not getting binded

A

Class needs to be public non abstract with default parameterless constructor, public setter properties, not fields

The key might be missing

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

What if key is in lowercase

A

Binding is case insensitive

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

Why array values missing

A

When same key in different providers, the array is replaced, not merging of values

15
Q

Mechanism of logging

16
Q

Logging Providers

17
Q

Log Levels

22