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>
  • &lt;p&gt;&lt;/p&gt;
  • {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.

Leave a Reply