What is HTML Helpers in MVCThe ASP.NET MVC framework includes helper methods that provide an easy way to render HTML in a view.Below render CheckBox in MVC Application<%= Html.CheckBox("bookType") %>TextBox HelperEnter your name: <%= Html.TextBox("name") %>List out the HTML Helpers Available in MVCActionLink — Links to an action method.BeginForm * — Marks the start of a form and links to the action method that renders the form.CheckBox * — Renders a check box.DropDownList * — Renders a drop-down list.Hidden — Embeds information in the form that is not rendered for the user to see.ListBox — Renders a list box.Password — Renders a text box for entering a password.RadioButton * — Renders a radio button.TextArea — Renders a text area (multi-line text box).TextBox * — Renders a text boxWhat is the AJAX Helpers in ASP.NetAJAX Helpers are used to create AJAX enabled elements like as Ajax enabled forms and links which performs request asynchronously. AJAX Helpers are extension methods of AJAXHelper class which exist in System.Web.Mvc namespace.Following example shows how to use AJAX action link using action and controller in Asp.Net MVC.@Ajax.ActionLink("Fatch Data", "GetData", new AjaxOptions {UpdateTargetId = "Data-container", HttpMethod = "GET" })Here is the html output of above code block.<a data-ajax="true" data-ajax-method="GET" data-ajax-mode="replace" data-ajax-update="#Data-container" href="/Home/GetData"> Fatch Data </a>

What is JSON Binding in MVC?JavaScript Object Notation (JSON) binding support started from ASP.Net MVC3 onwards via the new JsonValueProviderFactory, which allows the action methods to accept and model-bind data in JSON format. This is useful in Ajax scenarios like client templates and data binding that need to post data back to the server.What is Dependency Resolution in MVC?Dependency Resolver again has been introduced in ASP.Net MVC3 and it is greatly simplified the use of dependency injection in your applications. This turn to be easier and useful for decoupling the application components and making them easier to test and more configurable.Explain Bundle.Config in ASP.Net MVC4?"BundleConfig.cs" in ASP.Net MVC4 is used to register the bundles by the bundling and minification system. Many bundles are added by default including jQuery libraries like - jquery.validate, Modernizr, and default CSS references.What is the difference between View and Partial View

View

Partial View

It contains the layout page

It does not contain the layout page

Before any view is rendered, viewstart page is rendered

Partial view does not verify for a viewstart.cshtml. We cannot put common code for a partial view within the viewStart.cshtml.page

View might have markup tags like body, html, head, title, meta etc.

Partial view is designed specially to render within the view and just because of that it does not consist any mark up

View is not lightweight as compare to Partial View

We can pass a regular view to the RenderPartial method

How to perform validation in MVC ?one of the way to do validation in MVC using data annotations.it is attributes whih can be applied to model peoperties.See the below example.

How to use Jquery Plugins in ASP.Net MVC validation?We can use dataannotations for validation in ASP.Net MVC. If we want to use validation during runtime using Jquery then we can use Jquery plugins for validation. Eg: If validation is to be done on customer name textbox then we can do as :

What is ViewData and View Bag?ViewData, ViewBag is use for passing data from controller toview and in next request.

Viewdata contains the key, value pairs as dictionary and this is derived from class : "ViewDataDictionary". In action method we are setting the value for viewdata and in view the value will be fetched by typecasting.ViewData and ViewBag are almost similar.Similarity betweenViewData and View Bag1. Helps to maintain data when you move from controller to view.2. Used to pass data from controller to corresponding view.

3. Short life means value becomes null when redirection occurs. This is because their goal is to provide a way to communicate between controllers and views. It’s a communication mechanism within the server call.Difference between ViewBag & ViewData:ViewData is a dictionary of objects that is derived from ViewDataDictionary class and is accessible using strings as keys.ViewBag is a dynamic property that takes advantage of the new dynamic features in C# 4.0.ViewData requires typecasting for complex data type and check for null values to avoid error.ViewBag doesn’t require typecasting for complex data type.ViewBag & ViewData Example:

What is the TempDataTempData is use for Passing data from Controller to View in ASP.NET MVC.TempData in ASP.NET MVC is basically a dictionary object derived from TempDataDictionary.TempData stays for a subsequent HTTP Request as opposed to other options (ViewBag and ViewData) those stay only for current request. So, TempdData can be used to maintain data between controller actions as well as redirects.Below is sample example of TempData.

As in above example, we store an employee object in TempData in Controller Action 1 (i.e. TemporaryEmployee) and retrieve it in another Controller Action 2 (i.e. PermanentEmployee). But If we try to do the same using ViewBag or ViewData, we will get null in Controller Action 2 because only TempData object maintains data between controller actions.An important thing about TempData is that it stores contents in Session objectWhat is the REST ?Rest is Representational State Transfer.REST is an architectural style which uses HTTP protocol methods like GET, POST, PUT, and DELETE to access the data.ASP.Net MVC works in this style. In ASP.Net MVC 4 there is a support for Web API which uses to build the service using HTTP verbs.

What is the MVC ?MVC is a software architecture pattern for developing web application. It is handled by three objects Model-View-Controller.Model– It represents the application data domain. In other words applications business logic is contained within the model and is responsible for maintaining dataView– It represents the user interface, with which the end users communicates. In short all the user interface logic is contained within the VIEWController– It is the controller that answers to user actions. Based on the user actions, the respective controller responds within the model and choose a view to render that display the user interface. The user input logic is contained with-in the controller

Explain the Page LifeCycle of ASP.Net MVC

Below are the processed followed in the sequence.

App initializWhat is Separation of Concerns in ASP.NET ASP.Net MVCation

Routing

Instantiate and execute controller

Locate and invoke controller action

Instantiate and render view.

The main advantages of ASP.net MVC are

1.It provides RAD development

2.Enables the full control over the rendered HTML.

3.Easy integration with JavaScript frameworks.

4.Following the design of stateless nature of the web.

5.No ViewState and PostBack events

6.Support Full SEO using URL rewriting.

7.Easy development model for developers those coming from winform development

What is the Razor in ASP.NetRazor is not a new programming language itself, but uses C# syntax for embedding code in a page without the ASP.NET delimiters: <%= %> . It is a simple-syntax view engine and was released as part of ASP.NET MVC 3. The Razor file extension is "cshtml" for the C# languageRead below article for more about Razor.http://www.codeproject.com/Articles/639695/Getting-Started-with-Razor-View-Engine-in-MVCExplain what is routing? What are the three segments for routing is important?Routing helps you to decide a URL structure and map the URL with the Controller.The three segments that are important for routing isControllerNameActionMethodNameParameterExplain how routing is done in MVC pattern?There is a group of routes called the RouteCollection, which consists of registered routes in the application. The RegisterRoutes method records the routes in this collection. A route defines a URL pattern and a handler to use if the request matches the pattern. The first parameter to the MapRoute method is the name of the route. The second parameter will be the pattern to which the URL matches. The third parameter might be the default values for the placeholders if they are not determined.

Where is the route mapping code written in MVC?The route mapping code is written in "RouteConfig.cs" file and registered using "global.asax" application start event.For more details http://dotnet-magic.blogspot.in/2016/03/important-of-routeconfigcs-in-mvc.htmlCan we map multiple URL’s to the same action?Yes, you can, you just need to make two entries with different key names and specify the same controller and action.What is the attribute based routing in MVC This new feature introduce in MVC 5.By using the "Route" attribute we can define the URL structure. For example in the below code we have decorated the "GoAboutus" action with the route attribute. The route attribute says that the "GoAboutus" can be invoked using the URL structure "Users/about".

Mention what are the two ways to add constraints to a route?The two methods to add constraints to a route isUse regular expressionsUse an object that implements IRouteConstraint InterfaceBelow is example of Regular expression

The regular expression \d+ matches one or more integers. This constraint causes the Product route to match the following URLs:/Product/3/Product/8999But not the following URLs:/Product/apple/ProductWhat is the use of the default route {resource}.axd/{*pathinfo} ?This default route prevents request for a web resource file such as Webresource.axd or ScriptResource.axd from being passed to the controller.

What are child actions in ASP.Net MVC?To create reusable widgets child actions are used and this will be embedded into the parent views. In ASP.Net MVC Partial views are used to have reusability in the application. Child action mainly returns the partial viewsWhat is the ChildActionOnly attribute ?The ChildActionOnly attribute ensures that an action method can be called only as a child method from within a view. An action method doesn’t need to have this attribute to be used as a child action, but we tend to use this attribute to prevent the action methods from being invoked as a result of a user request. Having defined an action method, we need to create what will be rendered when the action is invoked. Child actions are typically associated with partial views, although this is not compulsory.1. [ChildActionOnly] allowing restricted access via code in View2. State Information implementation for specific page URL. Example: Payment Page URL (paying only once) razor syntax allows to call specific actions conditional