MVC Flashcards

1
Q

What is a tier 1 architecture?

A

All of the layers (business, data, presentation, etc…) are on the same machine

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

What is a tier 2 architecture?

A

The presentation layer or interface runs on a client, and a data layer or data structure gets stored on a server.

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

What is MVC?

A

MVC is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application.

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

Describe the model portion of the MVC.

A

The Model component corresponds to all the data-related logic that the user works with. This can represent either the data that is being transferred between the View and Controller components or any other business logic-related data.

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

Describe the view portion of the MVC.

A

The View component is used for all the UI logic of the application.

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

Describe the controller portion of the MVC.

A

Controllers act as an interface between Model and View components to process all the business logic and incoming requests, manipulate data using the Model component and interact with the Views to render the final output.

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

Describe the ActionResult class.

A

Represents the result of an action method. The ActionResult class is the base class for all action results. You decide which type of action result to return based on the task that the action method is performing.

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

Describe the ViewResult class.

A

Represents a class that is used to render a view.

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

Describe the JsonResult class.

A

An action result which formats the given object as JSON.

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

Describe the ContentResult class.

A

Represents a user-defined content type that is the result of an action method.

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

Describe the FileResult class.

A

Represents an ActionResult that when executed will write a file as the response.

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

Describe an action method.

A

Action methods are like normal methods with the following restrictions:

  1. Action methods must be public
  2. Action methods cannot be overloaded
  3. Action method cannot be a static method.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe enable code first migrations.

A

The migrations feature enables you to change the data model and deploy changes to production by updating the database schema without having to drop and re-create the database.

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

Describe what is unique about the code first migrations.

A

In production, when the application is running, it is usually storing data that you want to keep and you don’t want to lose everything each time you make a change such as adding a new column. Code First Migrations feature solves this problem by enabling Code First to update the database schema instead of dropping and recreating the database.

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

Describe the HtmlHelper class.

A

It supports the rendering of HTML controls in a view.

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

Describe model binding.

A

Model binding in ASP.NET Core MVC maps data from HTTP request to action method parameters. The parameters may be simple types such as strings, integers, or floats, or they may be complex types.

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

Describe tempdata.

A

Tempdata is a dictionary object used to share data between controller actions. Tempdata stays for subsequent HTTP request as opposed to other options like ViewBag and ViewData that stay only for the current request.

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

The ASP.NET MVC framework maps URLs to classes that are referred to as __________.

A

controllers

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

Describe what a controller does.

A

Controllers process incoming requests, handle user input and interactions, and execute appropriate application logic.

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

Describe what a controller class does.

A

A controller class typically calls a separate view component to generate the HTML markup for the request.

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

The controller defines ______ _______.

A

action methods

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

Describe the model portion of the MVC design pattern.

A

The model directly manages the data, logic and rules of the application. It expresses the applications behavior in terms of the problem domain.

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

Describe the view portion of the MVC design pattern.

A

A view can be any output representation of information, such as a chart or diagram. Multiple views of the same information are possible.

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

Describe the controller portion of the MVC design pattern.

A

The controller accepts input and converts it to commands for the model or view.

25
Q

Describe ViewData in MVC.

A

ViewData is a dictionary object that only transfers data from controller to view, not vice-versa and is only valid during the current request.

26
Q

Describe ViewBag in MVC.

A

ViewBag transfers data from controller to the view, ideally temporary data which in not included in a model.

27
Q

Describe the difference between ViewData and ViewBag in MVC.

A

ViewBag is able to set and get value dynamically and able to add any number of additional fields without converting it to strongly typed. ViewBag is just a wrapper around the ViewData.

28
Q

What are the four different types of filters offered in ASP.NET MVC framework?

A
  1. Authorization filter
  2. Action filter
  3. Result filter
  4. Exception filter
29
Q

Describe an action filter.

A

An action filter is an attribute that you can apply to a controller action that modifies the way in which the action is executed.

30
Q

Describe an authorization filter.

A

An authorization filter is an attribute makes security decisions about whether to execute an action method.

31
Q

Describe a result filter.

A

Result filters wrap execution of the ActionResult object.

32
Q

Describe an exception filter.

A

An exception filter executes if there is an unhandled exception thrown during the execution of the ASP.NET MVC pipeline.

33
Q

Describe the ways of passing data, in terms of action to view.

A
  1. ViewBag
  2. Pass the model
  3. ViewData
  4. TempData
  5. Session
34
Q

Describe ways of passing data on the client side.

A
  1. Local storage
  2. Cookies
  3. Cache
  4. Session storage
35
Q

Describe the different types of views.

A
  1. Static page
  2. Strongly typed page
  3. Layout
  4. Partial
36
Q

Describe the ways of passing data on the server side.

A
  1. ViewBag
  2. ViewData
  3. TempData
  4. Session
  5. Application
37
Q

Describe the difference between var and dynamic.

A

Var will predict the value at compile time, dynamic predicts the value at run time.

38
Q

Describe the difference between read and keep in tempdata.

A

read the value will be deleted after and keep will read the value and keep the value

39
Q

Describe how you would pass data from one view to another view.

A

Tempdata

40
Q

Describe the difference between textboxfor and editorfor.

A

Editor for will detect the model type and generate the proper input type. For example, if the model type was an enum, it would generate a drop down column.

41
Q

Describe the processing stages that the controller class is responsible for.

A
  1. Locating the appropriate action method to call and validating that it can be called.
  2. Getting the values to use as the action method’s arguments.
  3. Handling all errors that might occur during the execution of the action method.
  4. Providing the default WebFormViewEngine class for rendering ASP.NET page types (views).
42
Q

Name the two life cycles of MVC.

A
  1. The application life cycle

2. The request life cycle

43
Q

What are the different components of the request life cycle?

A
  1. Routing
  2. Controller initialization
  3. Action execution
  4. Result execution
  5. View Engine (Not always part of the cycle)
  6. Result execution
44
Q

Describe the routing part of the request life cycle.

A

During the routing part of the request life cycle the request is passes through the routing engine and the URL Routing Module decides how the request should be handled. The URL Routing Module does this by matching the incoming URL to the routes we defined in our application. All routes have an associated route with them.

45
Q

Describe the controller initialization phase of the request life cycle.

A

The MVC framework handles the route data by converting it into a concrete controller that can handle incoming requests.

46
Q

Describe the action execution phase of the request life cycle.

A

A component called the action invoker finds and selects an appropriate Action method to invoke the controller.

47
Q

Describe the result execution phase of the request life cycle.

A

MVC separates declaring the result from executing the result. If the result is a view type, the View Engine will be called and it’s responsible for finding and rending our view.

If the result is not a view, the action result will execute on its own. This Result Execution is what generates an actual response to the original HTTP request.

48
Q

Describe routing, in terms of, the MVC framework.

A

Routing is the process of directing an HTTP request to a controller.

49
Q

What is a strongly typed view in ASP.NET MVC?

A

A view used to render a specific type of model.

50
Q

What does the View do?

A

manages presenting information to the user

51
Q

What is the Model?

A

a represention of the state of data in the program

52
Q

What does the Controller do?

A

communication between the model and the view

53
Q

What HTML helper is used to prevent cross site request forgery (CSRF)?

A

@HTML.AntiForgeryToken()

54
Q

What do you use in order to query from your database with LINQ?

A

DBcontext

55
Q

Which method do you use in order to insert a record into the database with LINQ?

A

.Add()

56
Q

Which method is used to change the state of an object?

A

.Entry()

57
Q

Which property do you set within the Entry method in order to change the state of an object?

A

State

58
Q

Which method is used in order to persist changes to the database?

A

.SaveChanges()

59
Q

Which property is used if you wish to edit a record in the database?

A

EntityState.Modified