Friday, December 18, 2015

Most ask Question in ASP.net MVC Interview

     What is ViewModel in ASP.NET MVC?

Ans. In ASP.NET MVC, ViewModel is a class that contains the fields which are represented in the strongly-typed view. It is used to pass data from controller to strongly-typed view.

Key Points about ViewModel

ViewModel contain fields that are represented in the view (for LabelFor, EditorFor, DisplayFor helpers) ViewModel can have specific validation rules using data annotations.

ViewModel can have multiple entities or objects from different data models or data source.

  Explain ASP.NET MVC pipeline?

Ans.       The detail ASP.NET MVC pipeline is given below:

1.       Routing - Routing is the first step in ASP.NET MVC pipeline. Typically, it is a pattern matching system that matches the incoming request to the registered URL patterns in the Route Table.

The UrlRoutingModule(System.Web.Routing.UrlRoutingModule) is a class which matches an incoming HTTP request to a registered route pattern in the RouteTable(System.Web.Routing.RouteTable).


asp.net mvc Interview Question and answer in most interview

Q1.       What is MVC?

Ans. MVC stands for Model-View-Controller. It is a software design pattern which was introduced in 1970s. Also, MVC pattern forces a separation of concerns, it means domain model and controller logic are decoupled from user interface (view). As a result maintenance and testing of the application become simpler and easier.

Q2.       Explain MVC design pattern?

Ans.       MVC design pattern splits an application into three main aspects: Model, View and Controller

Model - The Model represents a set of classes that describe the business logic i.e. business model as well as data access operations i.e. data model. It also defines business rules for data means how the data can be changed and manipulated.

View - The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the controller as the result. This also transforms the model(s) into UI.


Controller - The Controller is responsible to process incoming requests. It receives input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Typically, it acts as the coordinator between the View and the Model.


What is Domain Driven Design and Development?

Ans. Domain-Driven Design (DDD) is a collection of principles and patterns that help developers to take design decisions to develop elegant systems for different domains. It is not a technology or methodology.

The main components of DDD are: Entity, Value Object, Aggregate, Service and Repository.

Entity- An object that has an identity- it is unique within the system, like Customer, Employee etc.

Value Object- An object that has no identity within the system like Rate, State etc.

Note: A value object can become an entity depending on the situation.

Aggregate: An aggregate root is a special kind of entity that consumers refer to directly. All consumers of the aggregate root are called as aggregate. The aggregate root guarantees the consistency of changes being made within the aggregate.

Service- A service is a way of dealing with actions, operations and activities within your application.

Repository- A repository is responsible to store and to retrieve your data. It is not a concern how and where data will be persist. So, it can be SQL server, oracle, xml, text file or anything else. Repository is not a Data Access Layer but it refers to a location for storage, often for safety or preservation.




What is MVP pattern?

Ans. This pattern is similar to MVC pattern in which controller has been replaced by the presenter. This design pattern splits an application into three main aspects: Model, View and Presenter.

Model - The Model represents a set of classes that describes the business logic and data. It also defines business rules for data means how the data can be changed and manipulated.

View - The View represents the UI components like CSS, jQuery, html etc. It is only responsible for displaying the data that is received from the presenter as the result. This also transforms the model(s) into UI.

Presenter - The Presenter is responsible for handling all UI events on behalf of the view. This receive input from users via the View, then process the user's data with the help of Model and passing the results back to the View. Unlike view and controller, view and presenter are completely decoupled from each other’s and communicate to each other’s by an interface.

Also, presenter does not manage the incoming request traffic as controller.


This pattern is commonly used with ASP.NET Web Forms applications which require to create automated unit tests for their code-behind pages. This is also used with windows forms.

Key Points about MVP Pattern

1.       User interacts with the View.

2.       There is one-to-one relationship between View and Presenter means one View is mapped to only one Presenter.

3.       View has a reference to Presenter but View has not reference to Model.

4.       Provides two way communication between View and Presenter.

Tuesday, June 2, 2015

What's Thread.Sleep() in threading ?

Thread's execution can be paused by calling the Thread.Sleep method. This method takes
an integer value that determines how long the thread should sleep. Example
Thread.CurrentThread.Sleep(2000).

What is Multi-threading ?

Multi-threading forms subset of Multi-tasking. Instead of having to switch between
programs this feature switches between different parts of the same program. Example
you are writing in word and at the same time word is doing a spell check in background.

What is Multi-tasking ?

It’s a feature of modern operating systems with which we can run multiple programs at
same time example Word, Excel etc.

What is the difference between Convert.toString and .toString()
method ?

Just to give an understanding of what the above question means seethe below code.
int i =0;
MessageBox.Show(i.ToString());
MessageBox.Show(Convert.ToString(i));
We can convert the integer “i” using “i.ToString()” or “Convert.ToString” so what’s the difference.
The basic difference between them is “Convert” function handles NULLS while “i.ToString()”
does not it will throw a NULL reference exception error. So as good coding practice using
“convert” is always safe.

How to prevent my .NET DLL to be decompiled?

By design .NET embeds rich Meta data inside the executable code using MSIL. Any one can easily
decompile your DLL back using tools like ILDASM (owned by Microsoft) or Reflector for
.NET which is a third party. Secondly there are many third party tools which make this decompiling
process a click away. So any one can easily look in to your assemblies and reverse engineer them
back in to actual source code and understand some real good logic which can make it easy to
crack your application.
The process by which you can stop this reverse engineering is using “obfuscation”. It’s a technique
which will foil the decompilers. There are many third parties (XenoCode, Demeanor for .NET)
which provide .NET obfuscation solution. Microsoft includes one that is Dotfuscator Community
Edition with Visual Studio.NET.