Getting Started Flashcards
When was the mvc pattern first introduced?
1970’s using a language called Smalltalk-76
Why is MVC so popular among Microsoft developers?
ASP.NET MVC has a separation of concerns.,
ASP.NET MVC provides testability out of the box.,
ASP.NET MVC has a smaller “View” footprint.
ASP.NET MVC has more control over HTML.
What’s the purpose of the App_Data folder?
it’s meant to hold data for your application (just as the name says). A couple of examples would include any kind of data files (XML, JSON, )
What’s the purpose of the App_Start folder?
The App_Start folder contains the initialization and configuration of different features of your application.
What’s the purpose of the Content folder?
This folder is meant for all of your static content like images and style sheets.
What’s the purpose of the Views/Shared folder?
The Shared folder is meant for any shared cshtml files you need across the website.
What’s the purpose of the Global.asax file?
The Global.asax is meant for the initialization of the web application.
What’s the purpose of the Web.Config file?
The web.config is where you place configuration settings for your application. For new MVC developers, it’s good to know that you can place settings inside the tag and place connection strings inside the tag.
Give a quick overview of a page request in MVC.
Routing
Identification and creation of a controller
Identify and select the method to execute
execute result
data replaced in the view
What are ActionResults?
a way to tell the controller what to return to a View or what to return to the browser. ActionResults are what you want to return when you are done processing your Action method.
What’s the difference between a ViewResult and an ActionResult?
ViewResult is a type of ActionResult. ViewResult is inherited from an ActionResult. There are a number of additional ActionResults
What is an ActionFilter?
an attribute that is attached to a controller or action method to perform a certain task.
What is ViewData?
Defined as a dictionary object in the controller class, the ViewData assigns a key/value pair to pass the data over to the View.
Since this is part of the controller class, we do not need to explicitly pass it to the View. It will automatically send it over. Not strongly typed I don’t think
What does the @ symbol do in the view for Razor
You need to prefix your code with an @ symbol to display any data from your models.
What is ViewBag?
ViewBag is a little bit better when it comes to passing data. It wraps the ViewData and makes the object type dynamic so we can immediately find it in our View.
What is TempData?
another type of dictionary in the controller called TempData. TempData is set once and when the request and response are complete, it is removed and never used again.
How do you redirect to a new action?
RedirectToAction(‘actionName’)
What is ViewModel?
ViewModel is strictly a container to hold Models for the View. It’s just a container to transport the data. ViewModels are different. When you pass a ViewModel from a controller to a View, you have to pass it through the View() method at the end of your Action method. In your View, you need to include the model type at the very top. This explains to the Razor ViewEngine what objects this view will use. The ViewModel method of passing data provides a solid way to build your Views using strong-typed objects instead of “magic-strings” or dynamic objects.
What is the ModelBinder?
is available to map all of the form data from the View into the current ViewModel and pass that into your controller.
What are HtmlHelpers? Give an example.
HtmlHelpers return generated HTML or Views.
@Html.TextBox(“FirstName”) ->
What are controller actions?
Public methods of our controllers.
What are action filters?
Introduce pre and post processing to actions
What is an ActionName attribute?
It’s an attribute you put on a action method to alias the method.
What is the importance of _ViewStart.cshtml
It will run before any of the other views in the application. You can register Layout settings in here.