1. Explain significance of routing?

-ASP.NET MVC uses ASP.NET routing, to map incoming browser requests to controller action methods.

-In ASP.NET Routing mechanism a routing table is maintained which is created when the web application first starts.

-The route table is present in the Global.asax file.

-In routing mechanism the physical path of page will not be used in URL and therefore hiding the application file system hierarchy from outer world.

-By using the routing mechanism the URL search becomes more user friendly.

2. Explain the main function of URL routing system in ASP.NET MVC?

-URL routing system provides flexibility to the system and it also enables to define new URL mapping rules that can be used with web applications.

-URL routing system is used to map the application and its routing information gets passed to right controller and action method.

-URL routing system processes and executes the method to run the application without using many designed rules.

-It is used to construct the outgoing URLs that can be used to handle the actions that have the ability to map both incoming and outgoing URLs that adds more flexibility to the application code.

-It follows the rules to execute the application globally and handle the logic that is required for the application.

3. Explain program to call the js function when the change is being made in the Dropdown list made in ASP.NET MVC?

- To call the function of the js (JavaScript) in the dropdown list in ASP.NET MVC the function has to be written like:
<script type="text/javascript">
function selectedIndexChanged() { }

- The function need to be called using the code nuggets or if the Razor view engine the the js has to be integrated as:

<%:Html.DropDownListFor(x => x.SelectProduct, new SelectList(Model.Products, "Value", "Text"), "Select product", new { id = "dpDown", onchange="selectedIndexChanged()" })%>

4. Explain ASP.NET MVC Request Life Cycle?

Following are the steps that are executed in ASP.NET MVC Request Life Cycle.

1. Application first receives the request and looks up Route object in RouteTable collection. Then the RouteData object is created.

2. Then RequestContext instance is created.

3. MvcHandler and pass RequestContext to handler is created.

4. Then IControllerFactory from RequestContext is identified.

5. Then the object of class that implements ControllerBase is created.

6. MyController.Execute method is called.

7. Then ControllerActionInvoker finds the action to invoke on the controller and executes that action on the controller and by calling the model associated view returns.

5. Explain the page lifecycle of an ASP.NET MVC?

The page lifecycle of ASP.NET MVC is having the following process and it is as follows:

-App initialization: in this the initiation of the application takes place that allow the application to interact the server and start to run the components.

-Routing: in this the messages are routed to the server for making the delivery of the request easier.

-Instantiate and execute controller: in this way the controller handles the request and passes it on to display the output or replies to the request.

-Locate and invoke controller action: The actions allow the controller to be located correctly and it invokes the correct action that has to be taken on the applications.

-Instantiate and render view: this helps in view the result of the application that is being built.

6. What is the difference between MVC (Model-View-Controller) and MVP (Model-View-Presenter)?

-MVC has the controller handling the important work and all the request from the applications are coming directly to the controller. Whereas, MVP has the View as the handler and it handles the requests that are being generated.

-MVC is used for web application to provide an easy interface through which the interaction can be done. Whereas, MVP is having the View as its first object that gets executed in the pipeline and it is responsible for passing the event to the Presenter.

-ASP.NET Webforms are hard to implement in MVC structure due to its complex architecture and giving the total control to the controller to handle the requests. Whereas, MVP divides the roles such, that it becomes easy to handle the requests and pass it from one model to another.

7. What is repository pattern in MVC.NET?

-Repository pattern is useful for decoupling entity operations form presentation, which allows easy mocking and unit testing.

-The Repository will delegate to the appropriate infrastructure services to get the job done. Encapsulating in the mechanisms of storage, retrieval and query is the most basic feature of a Repository implementation.

-Repository pattern is useful for decoupling entity operations form presentation, which allows easy mocking and unit testing.

-Most common queries should also be hard coded to the Repositories as methods. Which MVC.NET to implement repository pattern Controller would have 2 constructors on parameterless for framework to call, and the second one which takes repository as an input:

class myController: Controller
private IMyRepository repository;

// overloaded constructor
public myController(IMyRepository repository)
this.repository = repository;

// default constructor for framework to call
public myController()
//concreate implementation
myController(new someRepository());
public ActionResult Load()
// loading data from repository
var myData = repository.Load();

8. Explain Repository Pattern in ASP.NET MVC?

-Repository pattern is used as a default entity operation that allow the decoupling of the components used for presentation.

-Repository pattern allows easy testing in the form of unit testing and mocking.

-Repository pattern will have the proper infrastructure services to be used in the web applications.

-It uses the mechanism of encapsulating that provides storage, retrieval and query for the implementation of the repository.

-Repository patterns are hard coded in the application that is to be used in ASP.NET MVC architecture.

9. What are the namespaces used in ASP.NET MVC?

-All the namespaces and classes used for ASP.NET MVC reside in the System.Web.Mvc assembly.

-System.Web.Mvc namespace

This namespace provides classes and interfaces that support the MVC pattern for ASP.NET Web applications. This namespace also contains classes that manage controllers, controller factories, partial views, action results, views and model binders.

-System.Web.Mvc.Ajax namespace

This namespace provides classes that support Ajax scripts in an ASP.NET MVC application. The namespace also provides support of Ajax scripts and Ajax option settings.

-System.Web.Mvc.Async namespace

This namespace provides classes and interfaces that support asynchronous actions in an ASP.NET MVC application.

-System.Web.Mvc.Html namespace

This namespace provides classes that help in rendering HTML controls in an MVC application. The namespace contains classes providing forms, input controls, links, partial views, and validation support.

10. Explain the namespace classes used in ASP.NET MVC?

ASP.NET MVC uses the namespace classes that as follows:

-System.Web.Mvc namespace: this consists of classes and interfaces that follows MVC pattern to create web applications. This includes the controllers, libraries, actions, views, models.

-System.Web.Mvc.Ajax namespace: this consists of classes that support the AJAX scripts and used in the web applications. This also include the AJAX related settings and options.

-System.Web.Mvc.Async namespace: this consists of classes and interfaces that provide asynchronous actions in the web applications.

-System.Web.Mvc.Html namespace: this consists of classes in the form of helper application and follows the MVC pattern. This includes the forms, controls, links, views and validations.

Download Interview PDF