Skip to main content

Asp .net MVC Questions and Answers-3

Asp .net MVC Questions and Answers

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

Popular posts from this blog

Gemini software Dot net interview question for experienced

Gemini Interview questions 4-8 year experienced Dot net professional Gemini Interview questions 4-8 year experienced Dot net professional 1,Asp .net mvc request life cycle. 2,How routing works 3,Where codes for routing are written 4,What is attribute based routing in aap.net Mvc 5,Is multiple routes possible on a single action method. 6,What is action filters. 7,what is authentication and authorization filters 8,What are the types of authentication 8,What is the use of data annotation 9,Can we fire data annotation in client side. 10,What is model binding 11,what are Html helpers

15 Essential jQuery Interview Questions

15 Essential jQuery Interview Questions 15 Essential jQuery Interview Questions 1,Explain what the following code will do: $( "div#first, div.first, ol#items > [name$='first']" ) Ans:This code performs a query to retrieve any element with the id first, plus all elements with the class first, plus all elements which are children of the element and whose name attribute ends with the string "first". This is an example of using multiple selectors at once. The function will return a jQuery object containing the results of the query. 2,What is wrong with this code, and how can it be fixed to work properly even with buttons that are added later dynamically? // define the click handler for all buttons $( "button" ).bind( "click", function() {     alert( "Button Clicked!" ) }); /* ... some time later ... */ // dynamically add another button to the page $( "html" ).append( " Click...

ASP .Net MVC

ASp .Net MVC 1. Explain MVC (Model-View-Controller) in general? MVC (Model-View-Controller) is an architectural software pattern that basically decouples various components of a web application. By using MVC pattern, we can develop applications that are more flexible to changes without affecting the other components of our application. §    “Model”, is basically domain data. §    “View”, is user interface to render domain data. §    “Controller”, translates user actions into appropriate operations performed on model. 2. What is ASP.NET MVC? ASP.NET MVC is a web development framework from Microsoft that is based on MVC (Model-View-Controller) architectural design pattern. Microsoft has streamlined the development of MVC based applications using ASP.NET MVC framework. 3. Difference between ASP.NET MVC and ASP.NET WebForms? ASP.NET Web Forms uses Page controller pattern approach for rendering layout, whereas ASP.NET MVC uses Front con...