Asp .net MVC Questions and Answers
21) Explain how you
can send the result back in JSON format in MVC?
In order to send the result back in JSON format in MVC, you
can use “JSONRESULT” class.
22) Explain 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
|
23) List out the
types of result in MVC?
In MVC, there are twelve types of results in MVC where
“ActionResult” class is the main class while the 11 are their sub-types
ViewResult
PartialViewResult
EmptyResult
RedirectResult
RedirectToRouteResult
JsonResult
JavaScriptResult
ContentResult
FileContentResult
FileStreamResult
FilePathResult
24) Mention what is
the importance of NonActionAttribute?
All public methods of a controller class are treated as the
action method if you want to prevent this default method then you have to
assign the public method with NonActionAttribute.
25) Mention what 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.
26) Mention the order
of the filters that get executed, if the multiple filters are implemented?
The filter order would be like
Authorization filters
Action filters
Response filters
Exception filters
27) Mention what filters
are executed in the end?
In the end “Exception Filters” are executed.
28) Mention what are
the file extensions for razor views?
For razor views the file extensions are
.cshtml: If C# is the programming language
.vbhtml: If VB is the programming language
29) Mention what are
the two ways for adding constraints to a route?
Two methods for adding constraints to route is
Using regular expressions
Using an object that implements IRouteConstraint interface
30) Mention two
instances where routing is not implemented or required?
Two instance where routing is not required are
When a physical file is found that matches the URL pattern
When routing is disabled for a URL pattern
31) Mention what are
main benefits of using MVC?
There are two key benefits of using MVC
As the code is moved behind a separate class file, you can
use the code to a great extent
As behind code is simply moved to.NET class, it is possible
to automate UI testing. This gives an opportunity to automate manual testing
and write unit tests.
Comments
Post a Comment