ASP.NET (Core) MVC Interview Questions

Want to become an expert in cracking ASP.NET (Core) MVC interview questions?

Start with practicing the questions below. Whether a question involves multiple choice or live coding, we will give you hints as you go and tell you if your answers are correct or incorrect.

After that, take our timed public ASP.NET (Core) MVC Interview Questions Test.

To use our service for testing candidates, buy a pack of candidates.


1. Action Attributes

ASP.NET (Core) MVC Actions Public

Which statements are true about action attributes in ASP.NET (Core) MVC?

(Select all acceptable answers.)

Easy  
2min
   


2. Passing Data

ASP.NET (Core) MVC MVC pattern Public

Select all the methods that can be used to pass data from the controller to the view.

(Select all acceptable answers.)

Easy  
2min
   


3. Meal View

ASP.NET (Core) MVC Razor Public New

Consider the following C# model:

public class Meal
{
    public string Name { get; set; }
    public double Calories { get; set; }
    public List<string> Ingredients { get; set; }
}

The following template for Razor view engine accepts a Meal as model. Fill in the blanks with the simplest variants so that correct properties are printed.

<html>
<body>
  <h1>Name: </h1>
  <p>Calories: </p>
  <p>Ingredients:</p>
  <ul>
    @foreach (var ingredient in )
    {
        <li></li>
    }
  </ul>
</body>
</html>
Easy  
5min
   


4. User Controller

ASP.NET (Core) MVC Routing Public

Add appropriate routing attributes to the GetUsers and GetUserById actions so that:

  • GetUsers should activate on URL "/users".
  • GetUserById should activate on URLs "/users/userId" where userId is a string that represents the id of the user.
Easy  
5min
ASP.NET Core MVC Web 2 app, C# 7.0, .NET Framework 4.7  
 


  •   The GetUser action is correctly routed: Wrong answer
  •   The GetUserById action is correctly mapped: Wrong answer


5. Address Controller

ASP.NET (Core) MVC Actions Public

Consider the following view, provided here and below, which is placed in Views/Address/Create.cshtml:

@model Address

<!DOCTYPE html>
<html>
<head>
  <title>Create a new address</title>
</head>
<body>
  <form method="post" action="/user/address/save">
    <label asp-for="Street">Street:</label>
    <input type="text" asp-for="Street" />
    <label asp-for="City">City:</label>
    <input type="text" asp-for="City" />
    <input type="submit" value="Submit" />
  </form>
</body>
</html>

Add actions to the AddressController so that:

  • On requests to "user/address/create", the view above should be returned.
  • On submitting the form from the view above, AddressController should add the Address that was submitted into the AddressController.addresses field and then redirect to the "user/address/create" URL.

Actions should use attribute routing.

Easy  
20min
ASP.NET Core MVC Web 2 app, C# 7.0, .NET Framework 4.7  
 


  •   /user/address/create and /user/address/save URLs are mapped to distinct actions: Wrong answer
  •   /user/address/create URL returns expected view: Wrong answer
  •   Address is added to the AddressController.addresses list when the form is submitted: Wrong answer
  •   After saving the address, user is redirected to /user/address/create URL: Wrong answer


If you feel ready, take one of our timed public ASP.NET (Core) MVC Interview Questions tests:
  • ASP.NET (Core) MVC, HTML/CSS, JavaScript, C#, and SQL Online Test (Easy / Hard)
Not exactly what you are looking for? Go to our For Jobseekers section.