IBM ASP.NET MVC Recent Most common Interview Questions And Answers 2018
What is MVC 6?In MVC 6 ,the three frameworks,WebAPI ,MVC and SingnalR are merged into a single framework.Also in MVC dependency on System.Web is removed.
What is ASP.NET Core?
ASP.NET Core is a new version of ASP.NET.It is more than just another version of ASP.NET it is rewritten for web and cloud applications.
These are some of the most important MVC interview questions and answers which you should know when attending MVC interview.These questions will not only help you with the interview but would also help understand MVC better.
How To Enable Attribute Routing?
Just add @Model.CustomerName the method : "MapASP.Net MVCAttributeRoutes()" to enable attribute routing as shown below:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
//enabling attribute routing
routes.MapASP.Net MVCAttributeRoutes();
//convention-based routing
routes.MapRoute
(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Customer", action = "GetCustomerList", id = UrlParameter.Optional }
);
}
Explain Json Binding?
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.
Explain Dependency Resolution?
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 Are The Sub Types Of Actionresult?
ActionResult is used to represent the action method result. Below are the subtypes of ActionResult :
ViewResult
PartialViewResult
RedirectToRouteResult
RedirectResult
JavascriptResult
JSONResult
FileResult
HTTPStatusCodeResult
What Are Non Action Methods In Asp.net Mvc?
In ASP.Net MVC all public methods have been treated as Actions. So if you are creating a method and if you do not want to use it as an action method then the method has to be decorated with "NonAction" attribute as shown below :
[NonAction]
public void TestMethod()
{
// Method logic
}
What Are Validation Annotations?
Data annotations are attributes which can be found in the "System.ComponentModel.DataAnnotations" namespace. These attributes will be used for server-side validation and client-side validation is also supported. Four attributes - Required, String Length, Regular Expression and Range are used to cover the common validation scenarios.
Why To Use Html.partial In Asp.net Mvc?
This method is used to render the specified partial view as an HTML string. This method does not depend on any action methods.
We can use this like below :
@Html.Partial("TestPartialView")
Explain The Types Of Scaffoldings?
Below are the types of scaffoldings :
Empty
Create
Delete
Details
Edit
List
Can A View Be Shared Across Multiple Controllers? If Yes, How We Can Do That?
Yes we can share a view across multiple controllers. We can put the view in the "Shared" folder. When we create a new ASP.Net MVC Project we can see the Layout page will be added in the shared folder, which is because it is used by multiple child pages.
Post a Comment