Search This Blog

Wednesday, June 16, 2021

Q31-Q35

Q31. Difference between Middleware and filters in .net core mvc?
Q32. Life cycle of dotnet 8 MVC application?
Q33. When to use middleware and when to use filters in .net core?
Q34: What is CLEAN or Onion architecture design pattern?

=======================================================================Q31. Difference between Middleware and filters in .net core mvc?

Answer:
Middlewares
1) They are part of .net core and have access to httpcontext objects. they can be present even is project is not in mvc, api structure. 
2) Good in case you want to do changtes at httpcontet objects like authentication etc. 

Filters
1) They are present only in case of MVC and api. 
2) Good in case you want tocheck something around MVC contexts objects like post action filter

=======================================================================Q32. Life cycle of .net core MVC application?

Answer:
Life cycle of .net core application consists of two parts = 1st life cycle part specific to .net core + 2nd General life cycle part of MVC. 
  1. program.cs
  2. Authentication, Authorization etc middlewares
  3. Routing middleware will create routing map on hosted application server
  4. Controller 
  5. Action
  6. View
=======================================================================Q33. When to use middleware and when to use filters in .net core?

Answer:
Filters are something specific to MVC patterns that can be applied on top of our controllers. 
Filters and Middleware does the same functionality, but main difference lies in their scope. 

Middleware applies globally to all requests. eg : logging request and response, Handling exceptions globally, Managing CORS, Authentication/ Authorization. 

Filters applies specifically to a controller to an action of a controller. its mainly used to do validation of the model. 

=======================================================================






=======================================================================
Q34: What is CLEAN or Onion architecture design pattern?

Answer:
The Clean Architecture, often also referred to as Onion Architecture, is a software design pattern that aims to separate concerns and enforce dependency inversion, making systems more maintainable, testable, and adaptable to changes.
     
Key Concepts:
Clean Architecture is composed of layers arranged like an onion, where:
Core logic is at the center and Outer layers depend on inner layers, but not the other way around.



=======================================================================

No comments:

Post a Comment

Q36-Q40(EF)

Q36.  What is the difference between Include and Join in entity framework? Q37. What will be your approach in case you want to call a manual...