Asp Net Mvc Interview Questions With Answers

2 Explain the concept of MVC Scaffolding?


ASP.NET Scaffolding is a code generation framework for ASP.NET Web applications. Visual Studio 2013 includes pre-installed code generators for MVC and Web API projects. You add scaffolding to your project when you want to quickly add code that interacts with data models. Using scaffolding can reduce the amount of time to develop standard data operations in your project.

Scaffolding consists of page templates, entity page templates, field page templates, and filter templates. These templates are called Scaffold templates and allow you to quickly build a functional data-driven Website.

Scaffolding Templates


It creates a View that helps in creating a new record for the Model. It automatically generates a label and input field for each property in the Model.


It creates a list of records from the model collection along with the delete link with delete record.


It generates a view that displays the label and an input field of the each property of the Model in the MVC framework.


It creates a View with a form that helps in editing the current Model. It also generates a form with label and field for each property of the model.


It generally creates a View with the help of a HTML table that lists the Models from the Model Collection. It also generates a HTML table column for each property of the Model.

Learn more here – Terminologies in MVC: Part 3 (Scaffolding)

1 Explain what is the difference between View and Partial View?


  • It contains the layout page.
  • Before any view is rendered, viewstart page is rendered.
  • A view might have markup tags like body, HTML, head, title, meta etc.
  • The view is not lightweight as compare to Partial View.
  • Partial View

  • It does not contain the layout page.
  • Partial view does not verify for a viewstart.cshtml.We cannot put common code for a partial view within the
  • Partial view is designed specially to render within the view and just because of that it does not consist any mark up.
  • We can pass a regular view to the RenderPartial method.
  • Learn more here – Partial View in MVC

    Server Side Validation in MVC?


    The ASP.NET MVC Framework validates any data passed to the controller action that is executing, It populates a ModelState object with any validation failures that it finds and passes that object to the controller. Then the controller actions can query the ModelState to discover whether the request is valid and react accordingly.

    I will use two approaches in this article to validate a model data. One is to manually add an error to the ModelState object and another uses the Data Annotation API to validate the model data.

    Approach 1 – Manually Add Error to ModelState object

    I create a User class under the Models folder. The User class has two properties “Name” and “Email”. The “Name” field has required field validations while the “Email” field has Email validation. So lets see the procedure to implement the validation. Create the User Model as in the following,

    After that I create a controller action in User Controller (UserController.cs under Controllers folder). That action method has logic for the required validation for Name and Email validation on the Email field. I add an error message on ModelState with a key and that message will be shown on the view whenever the data is not to be validated in the model.

    Thereafter I create a view (Index.cshtml) for the user input under the User folder.

    Top MVC Interview Questions And Answers | ASP.NET MVC Interview Questions And Answers | Simplilearn

    Related Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *