ASP.NET MVC Interview Questions Part - II Day 26

Lecture 26 : ASP.NET MVC Interview Questions Part - II

1) How is the URL structure of MVC core ?
  • URL structure of MVC core is controller name with action name.

  • Example : localhost:1234/{controller}/{action name}. The "localhost:1234" is considered as a controller name.

2) If the view name is different than action name how to invoke it ?
  • If the view name is different from action name we have to write and the view in double quotes.

3) How do we define navigation using anchor tag ?
  • The HTML <a> element (also called the anchor element), containing its href attribute, creates a hyperlink to other web pages, locations within the same page, location to a specified title of another web page, or to an email web page. 

  • The <a> tag defines a hyperlink, which is used to link from one page to another.

  • The navigations can be defined using anchor tag as <a href="/Controller name/Action name"></a>.

4) How to pass model to the view ?
  • The other way of passing an object of the model class to the View. 

  • Erase the code of ViewData and pass the object of model class in return view. 

  • Example : return View("View Name" , Models (Objects) );

5) What is a strongly typed view and how do we create them ?
  • The view which binds to a specific type of ViewModel is called as Strongly Typed View.

  • Strongly Typed View are those views by which we can have intellisence and how to create them you define @model at the top.

  • The Model property then returns the type declared and this type of the Model is now known at the compile time, we get the advantage of IntelliSense and compile time error checking.

Model vs model :
  • It is easy to mix up with the Model and model.

  • The model is directive that is used to declare the type of the ViewModel.

  • The Model is a variable used to access the ViewModel. 

  • The type of Model is declared by the keyword @model.

6) How can we change the startup controller name and action name ?
  • In MVC you can change controller and action location in URL by doing some changes in RouteConfig.cs.
  • For Example : In your application if Home is controller  name and Index is action name  so by default URL created to access it will be :
7) What is routing ?
  • Routing is nothing but user-friendly URL.
  • It is to define URL structure and you map that URL structure with the method name and action name.

Comments

Popular posts from this blog

Basic Concept In C Sharp Day 16

Understanding C Sharp Day 18

Learn Garbage Collection Day 21