backend development for .net full stack coursera week 1 answers
MVC Basics Practice Quiz
1. What is Razor view engine in ASP.NET Core?
- It is a view engine for generating HTML markup using Razor syntax
- It is a view engine for generating XML markup using Razor syntax
- It is a view engine for generating JSON using Razor syntax
- It is a view engine for generating JavaScript using Razor syntax
2. Which of the following is a valid Razor syntax for rendering a HTML tag in a view?
- <p><p>
- <p></p>
- <p></p>
- {p}{/p}
3. What is the difference between convention-based routing and attribute-based routing in ASP.NET Core?
- There is no difference between them.
- Convention-based routing uses attributes to define the routing, while attribute-based routing uses a convention to define the routing.
- Convention-based routing uses a convention to define the routing, while attribute-based routing uses attributes to define the routing.
- Convention-based routing is used for routing in MVC applications, while attribute-based routing is used for routing in Web API applications.
4. Which of the following is a valid example of using ViewData in ASP.NET Core?
- ViewData[“message”] = “Hello World”;
- ViewData[“Hello World”] = message;
- ViewData[message] = “Hello World”;
- ViewData.message = “Hello World”;
ASP.Net Core - Practice Quiz
5. What is the main difference between strongly typed and weakly typed forms in ASP.NET Core?
- Strongly typed forms use a model to define the form fields and their data types, while weakly typed forms do not use a model and rely on HTML helpers to generate form fields.
- Strongly typed forms can only be used with Razor syntax, while weakly typed forms can be used with any syntax.
- Strongly typed forms are only supported in the latest version of ASP.NET Core, while weakly typed forms are supported in all versions.
- Strongly typed forms are faster and more efficient than weakly typed forms, but are harder to implement.
6. What is model binding in ASP.NET Core?
- A technique for automatically mapping HTTP request data to action method parameters or model properties.
- A way to enforce strong typing in your HTML form fields.
- A method of client-side validation using JavaScript.
- A way to define the layout and structure of your Razor views.
7. How can you handle a form post in ASP.NET Core?
- By creating an action method in your controller that accepts the form data as parameters.
- By creating a separate class to handle the form post and using dependency injection to inject it into your controller.
- By using a middleware component to intercept the form data before it reaches your controller.
- By creating a custom HTML helper to handle the form post and generate the necessary HTML and JavaScript.
8. What is client-side validation in ASP.NET Core?
- A technique for validating user input on the client using JavaScript.
- A technique for validating user input on the server before processing it.
- A method for storing user input in a database for later retrieval.
- A technique for encrypting user input to prevent it from being intercepted during transmission.
ASP.NET Core - Graded Quiz
9. What is middleware in ASP.NET Core?
- A type of filter used to modify incoming HTTP requests and outgoing HTTP responses.
- A mechanism for handling exceptions and logging errors in ASP.NET Core.
- Software components that are used to handle HTTP requests and responses in the ASP.NET Core pipeline.
- A technique for defining routes and URLs in an ASP.NET Core application.
10. What is the purpose of the ASP.NET Core pipeline?
- To define routes and URLs for an ASP.NET Core application.
- To handle exceptions and logging errors in an ASP.NET Core application.
- To process incoming HTTP requests and generate outgoing HTTP responses in an ASP.NET Core application.
- To handle database queries and updates in an ASP.NET Core application.
11. Which of the following is an example of built-in middleware in ASP.NET Core?
- UseEndpoints
- StaticFiles
- UseRouting
- UseMvc
12. What is the purpose of custom middleware in ASP.NET Core?
- To define routes and URLs for an ASP.NET Core application.
- To handle exceptions and logging errors in an ASP.NET Core application.
- To extend the functionality of the ASP.NET Core pipeline beyond the built-in middleware.
- To handle database queries and updates in an ASP.NET Core application.
13. Which attribute is used to specify the width of an image in HTML?
- height
- width
- size
- type
14. What is the purpose of middleware in ASP.NET Core?
- Middleware is used for defining the routing configuration of an ASP.NET Core application.
- Middleware is responsible for handling authentication and authorization in an ASP.NET Core application.
- Middleware is used to define the data models and entities in an ASP.NET Core application.
- Middleware is responsible for processing HTTP requests and generating HTTP responses in an ASP.NET Core application.
15. What is the purpose of middleware in ASP.NET Core?
- To define a set of controllers for a web application.
- To define the routing rules for a web application.
- To handle HTTP requests and responses in a web application.
- To define the models used in a web application.
16. Which of the following is NOT a type of ASP.NET Core filter?
- Authorization filter
- Action filter
- Result filter
- Content filter
17. What is the purpose of a custom filter in ASP.NET Core?
- To define the routing rules for a web application.
- To handle HTTP requests and responses in a web application.
- To modify the behavior of an ASP.NET Core action or result.
- To define the models used in a web application.
18. What is dependency injection in ASP.NET Core?
- A mechanism for handling exceptions in a web application.
- A way to manage authentication and authorization in a web application.
- A technique for creating and managing objects in a web application.
- A feature for caching frequently accessed data in a web application.
19. Which of the following is a built-in middleware in ASP.NET Core?
- Map
- UseSession
- UseMvc
- UseAuthentication
20. What is the purpose of dependency injection in software development?
- Dependency injection is a technique for eliminating code duplication in an application.
- Dependency injection is a way to achieve loose coupling between software components.
- Dependency injection is a technique for optimizing performance and memory usage in an application.
- Dependency injection is a design pattern used to enforce encapsulation in object-oriented programming.
21. Which of the following is NOT a built-in filter in ASP.NET Core?
- AuthorizeFilter
- ExceptionFilter
- CustomFilter
- ResultFilter
22. What is the purpose of the [HttpGet] attribute in ASP.NET Core?
- To specify that a controller action should only be accessible via the GET HTTP method.
- To specify that a controller action should only be accessible via the POST HTTP method.
- To specify that a controller action should only be accessible via the PUT HTTP method.
- To specify that a controller action should only be accessible via the DELETE HTTP method.
23. What is the purpose of dependency injection (DI) in ASP.NET Core?
- To enable server-side sessions.
- To add MVC to the request pipeline.
- To facilitate loose coupling and improve testability of code.
- To enable authentication and authorization.
24. Which of the following is a common way to handle exceptions in ASP.NET Core?
- Using try-catch blocks in the application code.
- Using the built-in middleware for exceptions handling.
- Using custom filters for exceptions handling.
- Using a third-party logging library to handle exceptions.
25. Which of the following is an advantage of using structured logging over traditional logging?
- Structured logging is faster than traditional logging.
- Structured logging is easier to read and analyze than traditional logging.
- Structured logging takes up less disk space than traditional logging.
- Structured logging is more customizable than traditional logging.
26. Which of the following is a recommended approach for logging sensitive data in an ASP.NET Core application?
- Log the data as plaintext in the log files.
- Use encryption to protect the data before logging it.
- Use a third-party logging library to handle sensitive data.
- Do not log sensitive data at all.
27. Which of the following is an advantage of using a centralized logging system?
- It is more difficult to analyze logs from multiple sources.
- It allows for more granular control over log data.
- It provides a single location to search for log data from multiple sources.
- It is more cost-effective than using multiple logging systems.
28. Which of the following is a common approach to handling logging in an ASP.NET Core application?
- Using the built-in middleware for logging.
- Using a third-party logging library.
- Implementing custom filters for logging.
- Logging directly in the application code.