Top 16 ASP.NET MVC 5 Interview Questions and Answers 2020
Hey, This article captures the Top most IT Companies have been picking up these questions for interview panel discussion for senior most candidates. And I believe these questions and answers will boost up your skills.
Here are some frequently asked interview questions for beginners, advanced and experienced ASP.NET MVC 5 developers candidates to get placed at Top ranked IT companies.
People constantly also search for MVC interview questions and answers pdf, MVC interview questions for 5 years and above experience, MVC programming interview questions for experienced professionals, c# interview questions with real time examples, with ebooks.
Let's begin now,
ASP.NET MVC 5
1. What is the difference between using Url.Action and Html.ActionLink in a view?
Action will generate only the URL, ActionLink will generate a complete a href tag with the URL
Action will use controller and action to get the URL, ActionLink will use the action only
ActionLink will generate only the URL, Action will generate a complete href tag with the URL
ActionLink will use controller and action to get the URL, Action will use the action only
2. Which of these is an MVC filter type?
Exception filter
Routing filter
Directory filter
ActionLink will use controller and action to get the URL, Action will use the action only
3. Which method would be overridden in an action filter to execute code just before an action?
OnActionExecuting
OnActionExecuted
OnActionPreExecuted
OnActionPreExecution
4. Which handles the initial step in the ASP.NET MVC request life cycle?The routing tableThe modelThe controllerThe view
4. Which handles the initial step in the ASP.NET MVC request life cycle?
The routing table
The model
The controller
The view
5. What filter requires a user to be logged in and denies access to anonymous users?The Authorize attribute without parameters - [Authorize]The RequireLogin attribute without parameters - [RequireLogin]The RequireLogin attribute with Authorize parameter - [RequireLogin(Authorize="")]The Authorize attribute with Required parameter - [Authorize(Required="*")]
5. What filter requires a user to be logged in and denies access to anonymous users?
The Authorize attribute without parameters - [Authorize]
The RequireLogin attribute without parameters - [RequireLogin]
The RequireLogin attribute with Authorize parameter - [RequireLogin(Authorize="")]
The Authorize attribute with Required parameter - [Authorize(Required="*")]
6. What are the ViewData and ViewBag objects used for?Both are used to pass data between the controller and viewViewBag is used to pass data between the controller and model, ViewData is used to pass data between model and viewBoth are used to pass data between the model and viewViewData is used to pass data between the controller and model, ViewBag is used to pass data between model and view
6. What are the ViewData and ViewBag objects used for?
Both are used to pass data between the controller and view
ViewBag is used to pass data between the controller and model, ViewData is used to pass data between model and view
Both are used to pass data between the model and view
ViewData is used to pass data between the controller and model, ViewBag is used to pass data between model and view
7. What step is required to apply a filter globally to every action in your application?Add a filter in the RegisterGlobalFilters method of the FilterConfig classAdd a filter in the RegisterRoutes method of the RouteConfig classAdd a filter reference in the <httpHandlers> element of the web.config fileAdd a filter reference in the <globalFilters> element of the web.config file
7. What step is required to apply a filter globally to every action in your application?
Add a filter in the RegisterGlobalFilters method of the FilterConfig class
Add a filter in the RegisterRoutes method of the RouteConfig class
Add a filter reference in the <httpHandlers> element of the web.config file
Add a filter reference in the <globalFilters> element of the web.config file
8. What can an action return to the browser?Basically anything, you can create custom action resultsHTML, JSON and filesViewsSerialized data
8. What can an action return to the browser?
Basically anything, you can create custom action results
HTML, JSON and files
Views
Serialized data
9. Which method has to be implemented in a result filter to catch the result after it's processed?OnResultExecutedAfterResultProcessedOnResultProcessedOnResultRun
9. Which method has to be implemented in a result filter to catch the result after it's processed?
OnResultExecuted
AfterResultProcessed
OnResultProcessed
OnResultRun
10. Which is a property of a controller that takes advantage of the new dynamic features in C# 4.0?ViewBagTempDataViewDataSession
10. Which is a property of a controller that takes advantage of the new dynamic features in C# 4.0?
ViewBag
TempData
ViewData
Session
11. Which jQuery method loads JSON-encoded data from the server using a GET HTTP request?getJSON()JSON()loadJSON()requestJSON()
11. Which jQuery method loads JSON-encoded data from the server using a GET HTTP request?
getJSON()
JSON()
loadJSON()
requestJSON()
12. What would be a good reason to use an exception filter?Redirect to a view customized to a certain type of exceptionManipulate the view result when an exception occursLog before or after an action executesException occur while view is loaded
12. What would be a good reason to use an exception filter?
Redirect to a view customized to a certain type of exception
Manipulate the view result when an exception occurs
Log before or after an action executes
Exception occur while view is loaded
13. You have created a custom validation annotation. What are the steps required to use it?Just use the annotation in a modelRegister the annotation in web.config, use the annotation in a modelRegister the annotation in the global.asax, use the annotation in a modelRegister the annotation in app.config, use the annotation in a model
13. You have created a custom validation annotation. What are the steps required to use it?
Just use the annotation in a model
Register the annotation in web.config, use the annotation in a model
Register the annotation in the global.asax, use the annotation in a model
Register the annotation in app.config, use the annotation in a model
14.Which of the following is a Result Filter?OutputCacheAttributeInputCacheAttributeOutputStoreAttributeInputStoreAttribute
14.Which of the following is a Result Filter?
OutputCacheAttribute
InputCacheAttribute
OutputStoreAttribute
InputStoreAttribute
15.Which class is used by default to map and bind HTTP request data with a model?DefaultModelBinderDefaultModelMapperDefaultRequestBinderDefaultRequestMapper
15.Which class is used by default to map and bind HTTP request data with a model?
DefaultModelBinder
DefaultModelMapper
DefaultRequestBinder
DefaultRequestMapper
16.What could be a good built-in ActionResult to return in response to an AJAX request from a browser in a MVC controller?JsonResultDataResultHttpResultAjaxResult
16.What could be a good built-in ActionResult to return in response to an AJAX request from a browser in a MVC controller?
JsonResult
DataResult
HttpResult
AjaxResult
0 Comments