Friday, April 9, 2021

ASP.NET MVC Interview Questions Part-2

 

ASP.NET MVC Interview Questions Part-2




1.How is the URL structure of MVC core ?

  • URL structure of MVC core is controller name with action name.
  • The URL structure of MVC core is  localhost :4200/{ controller} /{action name}.
  • The "localhost:4200" 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 than action name then we have to write view in double quotes("").







3.How do we define navigation using anchor tag ?

  • The navigations can be defined using anchor tag as <a href="/Controller name/Action name"></a>
  • 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.







4.How to pass model to the view ?

  • The other way of passing the data from Controller to View can be by 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.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 :











6.What is routing? 
  • Routing is a pattern matching system.
  • Routing is nothing but user-friendly URL.
  • It is used to move from one page to another  page.
  • It is to define URL structure and you map that URL structure with the method name and action name






6.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.















For more understanding watch below video :
Thank you!!!!


No comments:

Post a Comment

Function in SQL -part 8

  In this blog we are going to understand  Sql function.   FUNCTION: A function is a database object in SQL Server. It accepts only input pa...