Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Is it possible to implement Ajax in MVC if yes then how?

Answer»

Is it POSSIBLE to IMPLEMENT Ajax in MVC if YES then how?
Yes we can implement Ajax in MVC and to implement this we use Ajax libraries and JQUERY.

2.

One major difference between MVC and traditional ASP.NET web application

Answer»

One major difference between MVC and TRADITIONAL ASP.NET web application
In our traditional ASP.NET web forms application and in ASP application there is link between the url and page means if USER request page crackyourinterview.aspx from the server the user get same page from the disk where it is situated and one to one correspondence between a URL and a page.. If the SomePage.aspx file does not EXIST, you get an ugly 404 - Page Not Found error.
But the condition is CHANGED in MVC ASP.NET application there is no correspondence relation between the URL that you type into our browsers address bar and the files that we find in our application. URL is corresponds to a controller action instead of page on disk.
When we call page in traditional ASP.NET or ASP application the request are mapped to pages.ASP.NET MVC application, in contrast, browser requests are mapped to controller actions.
One more thing is that ASP.NET Web Forms application is content-centric and MVC Application is application logic centric.

3.

What do you mean by DispatcherServlet?

Answer»

What do you MEAN by DispatcherServlet?
DispatcherServlet is one of the class which get request that are INCOMING and ALSO maps down it to the most appropriate resource which includes Models, VIEWS and Controllers.

4.

How do we maintain a session in MVC?

Answer»

How do we maintain a session in MVC?
We can maintain a session in MVC and there are three different WAYS to do that. These are given below:-
(1)By TEMP data
(2)By view BAG
(3)By view data

5.

Advantage and disadvantage of MVC architecture

Answer»

Advantage and disadvantage of MVC architecture
Below are some of advantage and disadvantages of MVC architecture
Advantage
(1)When we use MVC architecture it will SEPARATE the user interface from the business logic, and the business logic from the data access logic. So MVC architecture increases flexibility and maintainability and scalability.
(2)Other advantage of MVC is reuse of components. For example if we want a windows user interface rather than a web browser interface, this can be done in an EASY and fast way by just replacing the UI component. All the other components like business logic and data access and the database remains the same. Layered architecture allows to swap and reuse components at will.
(3)MVC architecture helps us to do teams work on different parts of the application parallely with minimal dependencies on other teams.
(4)MVC architecture helps us to develop loosely coupled systems.
(5)In MVC we can create different components of the application which can be independently deployed and maintained and updated on different time SCHEDULES.
(6)MVC architecture also makes it possible to configure different levels of security to different components deployed on different boxes. So MVC architecture helps us to secure portions of the application behind the FIREWALL and make other components accessible from the Internet.
(7)MVC architecture also helps you to test the components independently of each other.
Disadvantage
(1)Becasue we need extra overhead due to layers which will do negative impact on the performance
(2)Development of user-intensive applications can sometime take longer if the layering prevents the use of user interface components that directly interact with the database.
(3)The use of layers helps to control and encapsulate the complexity of large applications but adds complexity to simple applications.
(4)Changes to lower level interfaces tend to percolate to higher levels and ESPECIALLY if the relaxed layered approach is used.

6.

Why to use NonActionAttribute in MVC

Answer»

When we TALK about controller class all the methods in it are TREATED as action methods by DEFAULT. But we can change this public method to PREVENT this by using NONACTIONATTRIBUTE.

7.

Define two ways to add constraints to a route in MVC?

Answer» DEFINE two ways to add constraints to a route in MVC?
Below are the two methods to add constraints to a route in MVC
(1)By using regular EXPRESSIONS
(2)By the USE of OBJECT that implements IRouteConstraint Interface.
8.

List common return types of a controller action method?

Answer»

List COMMON RETURN types of a controller action method?
Below are the list of common return types of a controller action method:-
(1)VIEW RESULT
(2)JAVASCRIPT Result
(3)Redirect Result
(4)JSON Result
(5)Content Result

9.

Write down some of common difference between Partial View and View in MVC?

Answer» WRITE down some of common DIFFERENCE between PARTIAL VIEW and View in MVC?
Below are the some of the common difference between Partial View and View.
10.

what is bundling and minification in mvc

Answer»

what is bundling and minification in mvc
Bundling and minification TECHNIQUES are mainly used to reduce request LOAD time by reducing number of request to the SERVER. Bundling is the technique where we group files likes css,js files and then request server in single attempt. So in place sending 2 or more files it will send them in one go which will save BANDWIDTH and load application faster.
Minification is the technique where we will remove extra spaces from js files and remove commented lines to lower the size of js files that helps in loading file FASTERS.

11.

Define two techniques like Minification and Bundling in MVC?

Answer» DEFINE two techniques like MINIFICATION and Bundling in MVC?
Minification and Bundling are two techniques included in MVC WHOSE primary function is to progress the request load time. This will advances the load time by dipping the QUANTITY of requests sent to the server as well as reducing the requested assets size(CSS and Javascript).
12.

What do you mean by TempData in MVC?

Answer»

What do you MEAN by TempData in MVC?
We can say TempData is one of the dictionary OBJECT which is being USED to store data for a short period of time. And we can say this is MVC TempDataDictionary class which is acts as a controller base-class INSTANCE property. And TempData has one of the ability to preserve data for an HTTP request.

13.

Different return types of a controller action method

Answer» DIFFERENT return types of a controller action method
ACTIONRESULT is a return type of controller method in asp.net mvc. There are many derived ActionResult types in MVC that we USE to return the result of a controller method to the VIEW. ActionResult is a return type of controller method in MVC. ActionResult is abstract class that has many subtypes. Below are the different return types of a controller action method:-
(1)ViewResult
(2)PartialViewResult
(3)ContentResult
(4)RedirectResult
(5)RedirectToRouteResult
(6)JsonResult
(7)EmptyResult
(8)FileResult
(9)JavaScriptResult
14.

Which one is faster MVC or ASP.NET

Answer»

Which one is faster MVC or ASP.NET
Before GOING to answer first i will provide some basic information on both of these then we will decide which will be faster.
MVC is actually an architectural pattern on the other hand ASP.NET is a framework to develop web APPLICATIONS. MVC uses mostly Html controls(Doesnt use server side controls like asp.net ) and Client Side Scripting(Jquery,javascript) for EVENT handling and some other purpose.
But there are SOM many other factor that will make the difference GIVEN below
(1)Project size
(2)Architecture design
(3)Database
(4)Coding technique and standard
We can use MVC pattern in any language such as JAVA, C#, PHP etc.

15.

What is ViewData in MVC

Answer»

What is ViewData in MVC
ViewData is similar to ViewBag. Which is useful in transferring data from Controller to View. ViewData have the key, value pairs as dictionary which drived from class "ViewDataDictionary". Its transfers data from controller to view but not vice-versa. And its valid only during the current request. In ACTION method we setting the value for ViewData and in view the value will be fetched by typecasting.



ViewData MVC

ViewData only LASTS during current http request. ViewData values will be cleared if redirection occurs.
ViewData value must be TYPE CAST before USE.

16.

Request Flow in ASP.NET MVC Framework

Answer»

Request Flow in ASP.NET MVC Framework
As in web every process has the flow from Client to Server. Same flow is followed in ASP.NET MVC framework but have some more process is followed. Once request is PASSED from client to server. Request hits the CONTROLLER coming from client. Controller now DECIDES which MODEL to use in ORDER to serve the request further. And then pass that model to View. Aftre that View will transofmrs the model and create a appropriate response that is rendered to the client.

17.

Can we create web application with both webforms and mvc?

Answer»

Can we create web application with both webforms and mvc?
Yes we can do that but we NEED to include mvc assembly references in web FORMS application for creating hybrid application. And below are the assemblies which need to USE
(1)System.Web.MVC
(2)System.Web.Razor
(3)System.ComponentModel.DataAnnotations

18.

Difference between TempData, viewData and ViewBag in MVC

Answer»

Difference between TempData, viewData and VIEWBAG in MVC
Below are the main DIFFERENCES between Temp data, View and View Bag
TempData
(1)class name is TempDataDictionary where TempData is derived from.
(2)We GENERALLY used TempData to pass data from current request to next request.
(3)TempData will keep the information for the time of HTTP Request. This means from one page to another. It helps to maintain the data when we move from one controller to another controller or from one action to another action.
(4)It genaraly requires typecasting for complex data types and checks for null VALUES to avoid error.
(5)We use TempData to store only one time messages like the error messages and validation messages

ViewData
(1)Class name ViewDataDictionary where ViewData is derived from.
(2)ViewData is used to pass data from controller to view.
(3)It is only available for current request only.
(4)It requires typecasting for complex data types and checks for null value to avoid error.
(5)IF any redirection done then its values becomes null.


ViewBag
(1)It is a DYNAMIC property which takes advantages of new dynamic

features in c# 4.0
(2)And ViewBag is used to pass data from the controller to respective view.
(3)It is same as ViewData means available for current request only.
(4)It will not requires typecasting for complex data type.
(5)If there some redirection occurs then its values becomes null.

19.

Advantages and Disadvantages of MVC model

Answer»

Advantages and Disadvantages of MVC model
Below are the most important advantages and disadvantages of MVC
Advantages
(1)All the classes and OBJECT here in MVC are independent of each other.
(2)It is very easy to manage and maintain the MVC.
(3)In MVC model development progresses in parallel.
(4)Each MVC object has different responsibilities.
(5)WIth the help of MVC it will clearly split business logic and presentation logic.
(6)Multiple developer can work at a time without effecting other developers.
(7)It helps in TTD so testing like unit test can easily be added to the application.
(8)MVC also Support default responsive web site and mobile templates in Latest version.
(9)We can create our own view engine with compare ti traditional view engine.

Disadvantages
(1)We cannot saw the design page preview liek .aspx in asp.net
(2)To do parallel development we need multiple experts programmers.
(3)The Model pattern is little complex.
(4)WIth MODERN user INTERFACE its quite difficult to use MVC.
(5)Data ACCESS in view is inefficient.
(6)We need to understand so many technologies to work on MVC.

20.

Could not load type System.Web.Mvc.ViewPage in asp.net MVC2

Answer»

To RESOLVE this issue we need to ADD below PAGE tag in web.config file in system.web section



< pages
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

21.

Different MVC version with there features

Answer»

Below are the five MVC version with there features
(1)Version MVC1 ASP.NET
(a)Comes on Mar 13, 2009
(b)DotNet 3.5 and with Visual Studio 2008 & Visual Studio 2008 SP1
(c)Pattern architecture MVC with WebForm Engine
(d)Support Helpers
(e)Support AJAX
(f)Routing Possible
(g)Have Unit Testing feature


(2)Version MVC2 Asp.Net

(a)Date of release Mar 10, 2010
(b)RUNS on .Net 3.5, 4.0 and with Visual Studio 2008 & 2010
(c)Strongly typed HTML helpers means lambda expression based Html Helpers
(d)Templated Helpers
(e)Support for Data Annotations Attribute
(f)ClientSide validation
(g)UI helpers with automatic scaffolding and customizable templates
(h)Attribute based model validation on both client and server
(i)Have feature of overriding the HTTP Method Verb including Put,GET,POST and DELETE
(j)Partitioning of large applications into modules
(k)have feature of Asynchronous controllers


(3)Version MVC3 Asp.Net

(a)Date of Release Jan 13, 2011
(b)Runs on .Net 4.0 and with Visual Studio 2010
(c)Have Razor view engine
(d)Better support for Data Annotations as compare to previous version
(e)Have Remote Validation
(f)Compare Attribute
(g)Have sessionless Controller
(h)Child Action Output Caching
(i)Dependency Resolver
(j)Entity Framework Code First support
(k)Partial-page output caching
(l)ViewBag dynamic property for passing data from controller to view
(m)Global Action Filters
(n)Better JavaScript support with unobtrusive JavaScript, jQuery Validation, and JSON binding
(o)Use of NuGet to deliver software and manage dependencies throughout the platform
(p)Have good intellisense support for Razor into Visual Studio

(4)Version MVC4 Asp.Net
(a)Date of Release Aug 15, 2012
(b)Runs on .Net 4.0, 4.5 and with Visual Studio 2010SP1 & Visual Studio 2012
(c)Included ASP.NET Web API
(d)Improvement in default project templates
(e)New feature Mobile project template using jQuery Mobile
(f)Improved DISPLAY Modes
(g)Task support for Asynchronous Controllers
(h)Bundling and minification
(i)Support for the Windows Azure SDK

(5)Version MVC2 Asp.Net Preview
(a)Date of Release Jun 26, 2013
(b)Runs on .Net 4.5, 4.5.1 and with Visual Studio 2013 Preview
(c)One Asp.Net
(d)Asp.Net Identity
(e)ASP.NET Scaffolding
(f)Authentication filters - run prior to authorization filters in the ASP.NET MVC pipeline
(g)Bootstrap in the MVC template
(h)ASP.NET Web API2

22.

Basic diagram of MVC

Answer»

Below diagram helps you to under stand what are the DIFFERENT three PARTS of MVC and what the PURPOSE of these three parts and what is there purpose in MVC:-



MVC Diagram

23.

Can you write down some syntax for Razor in MVC3

Answer»

Below i have GIVEN some syntax of razor as well as some comparison with the old technlogies used before Razor
(1)First for datetime
(i)New Razor code for datatime
DateTime.Now
(II)Old code for datetime
< % =DateTime.Now%>


(2)Syntax for ForEach loop
foreach (string obj in obj)
{
obj
}


(3)Code for multiple lines we will add at first row
{
LIST objlst = new List ();
objlst.Add("dotnet");
objlst.Add("java");
objlst.Add("php");
objlst.Add("sql");
}


(4)To HTML display with Razor
{
var link = "< a href='http://www.getproductprice.com'>CLICK here< /a>";
}link;
Here in above code you will get OUTPUT as < a href='http://www.getproductprice.com' >Click here


(5)ANd to display link we use below code
{
var link = "< a href='http://www.getproductprice.com' >Click here< /a>";
Html.Raw(link);
Now with above code will will get link Click Here only

24.

How to create Razor enable application in MVC3

Answer»

Before doing with RAZOR MVC3 you must install it. And one more THING is that MVC3 have some enhancement int it but some basic INPUTS are taken from MVC2.
(1)Below is the first screen to choose before creating Razor


razor mvc3
(2)(i)In second screen we pick Empty option to creates PROJECT becasue it take less amount of files.
(ii)Its also creates a shell application which includes user registration and authentication.
(iii)Here in this authentication takes place through domain or from Active Directory infrastructure.


mvc razor
(3)Below is the example of csharp project so cshtml file is created when we choose VB then vbhtml file is created

razor cshtml