Overblog Follow this blog
Edit post Administration Create my blog
June 17 2011 6 17 /06 /June /2011 15:24

Contents

So, what’s the agenda?
So why MVC when ASP.Net behind code was so good?
Problem number 1:- UNIT Testing
Problem 2 :- The reality of separation of code and UI
Our HERO MVC (Model, view and controller)
Pre-requisite for MVC
Lab1:- Creating a simple hello world ASP.NET MVC Application
    Video demonstration for Lab 1
        Step1:- Create project
        Step 2:- Add controller
        Step 3:- Add View
        Step 4:- Run the application
So what’s in the next Lab?
Lab2:- Passing data between controllers and views
    Video demonstration for Lab 2
        Step1:- Create project and set view data
        Step 2:- Display view data in the view.
So what’s in the next Lab?
Lab 3:- Creating a simple model using MVC
    Video demonstration for Lab 3
        Step1:- Create a simple class file
        Step2:- Define the controller with action
        Step3:- Create strongly typed view using the class
        Step 4 :- Run your application
So what’s in the next Lab?
Lab 4:- Creating simple MVC data entry screen
    Video demonstration for Lab 4
        Step1:- Creating your data entry ASPX page
        Step2:- Creating the controller
        Step3:- Create the view to display the customer object
        Step 4:- Finally run the project
So what’s in the next Lab?
Lab 5:- using HTML helper to create views faster
        Step 1:- Create the Customer class
        Step2:- Creating the input HTML form using helper classes
        Step 3:- Create a strong typed view by using the customer class
        Step4:- Creating the controller class.
What’s for the second day?

 

So, what’s the agenda?

As the article name says learn MVC, so the agenda is simple we are going to learn ASP.NET MVC  in 7 days.

The way we will learn MVC in this series of article is by doing Labs, looking at detail steps of how to achieve those labs and also looking at demonstrative videos.

This complete article is divided in to 7 days with 42 hands on labs and every day we will do 6 labs which will help us achieve our goals.

So get ready for day 1. In day1 below is our agenda we will start with introduction, do a simple hello world and finally in the 6th lab we will create a simple customer data entry screen using HTML helper classes.

 

Lab No. Lab description Youtube Video demonstration for the same
1 Introduction Why MVC? NA.
2 A simple Hello world ASP.NET MVC application. http://youtu.be/KAKxm4eQP24?hd=1
3 In this Lab we will see how we can share data between controller and the view using view data. http://youtu.be/Fu9v2MIDlTA?hd=1
4 In this lab we will create a simple customer model, flourish the same with some data and display the same in a view. http://youtu.be/0-UdqWy9lVc?hd=1 
5 In this lab we will create a simple customer data entry screen with some validation on the view. http://youtu.be/1dlxtHuRw34?hd=1 
6 This Lab will demonstrate how to expedite your MVC development process using HTML helper classes. Pending…
 



You can watch my .NET interview questions and answers videos on various sections like WCF, Silver light, LINQ, WPF, Design patterns, Entity framework etc


So why MVC when ASP.Net behind code was so good?

 

I am sure all ASP.NET love the behind code concept. Accepting something new like MVC will not convince them. So let’s analyze the problems with the current behind code stuff.

When we generally talk about ASP.NET application built on tiered architecture they are divided in four parts UI (ASPX pages), behind code (ASPX.CS pages), Middle tier (.NET classes) and finally Data layer.

If you see from the aspect of code distribution major code which has logic is in the middle tier or in the behind code (APX.CS files). The UI or ASPX files are HTML files which is more of UI design and data access logic are pretty much standard components like enterprise data blocks, entity data contexts etc.


Let’s try to analyze the problems.

Problem number 1:- UNIT Testing

From the aspect of unit testing we can exclude the data logic and the UI HTML. The data logic classes are already time tested components like enterprise data block, entity data context or LINQ data context. So we really do not have to put lot of effort on testing the DAL separately. In case you have custom data access layer it will be still easy to test them as they are simple .NET classes.

There is no logic in testing on ASPX HTML as such it’s more of look and feel.

The middle tier is again a simple .NET class like data logic so you can easily do unit testing using VSTS or NUNIT.

Now comes the most important one the behind code. The behind code has lot of action and testing them is one of the most important things. The only way to invoke these codes are by doing manual test. From a longer run perspective this would not be a great choice.

Even though www.microsoft.com   always boasted about how the ASP.NET behind code was separate from the UI, in practical sense it’s very difficult to decouple an ASP.NET behind code and do unit testing on them.

The ASP.NET behind code is completely tied up with ASP.NET Httpcontext object which makes unit testing very difficult.
Just think how do I unit test the below behind ASP.NET code. How do I create a Http context object , how do I simulate the sender and eventargs objects of the button clicks etc.

FYI: - Many developers would talk about mock test, rhino mocks etc but still its cryptic and the complication increases with session variables, view data objects, ASP.NET UI controls creating further confusion.

Problem 2 :- The reality of separation of code and UI

As said previously the ASPX and the ASPX.CS cannot be decoupled in reality thus reducing reusability. Yes, Microsoft did said first that the behind code is different and the UI is different but then they are probably separate physical files only and one cannot just exist without other.

For instance let’s say the same button click code when called via HTTP POST should display using displayinvoice.aspx and when called via HTTP GET should display in tree view. In other words we would like to reuse the behind code. Just think how can we do the same using the current behind code.


Our HERO MVC (Model, view and controller)

That’s where MVC comes to rescue. The behind code is moved to a simple .NET class called as controller. Any user request first comes to the controller class, the controller class then invokes the model and attaches the model to the view for display to the end user.

As this controller class is a simple .NET class we can reuse and also do unit testing easily. So let’s see how we can create MVC application using MVC template provided by visual studio.

Pre-requisite for MVC

Before we start the day lets ensure that you have all the ingredients to create a MVC application.

• Visual Studio 2010 or the free Visual Web Developer 2010 Express. These include ASP.NET MVC 2 template by default.
• Visual Studio 2008 SP1 (any edition) or the free Visual Web Developer 2008 Express with SP1. These do not include ASP.NET MVC 2 by default; you must also download and install ASP.NET MVC 2 from http://www.asp.net/mvc/  .

So once you have all your pre-requisite its time to start with the first lab.

Lab1:- Creating a simple hello world ASP.NET MVC Application

In this lab we will create a simple hello world program using MVC template. So we will create a simple controller, attach the controller to simple index.aspx page and view the display on the browser.

Video demonstration for Lab 1

In case you want spend more time with your family rather than reading the complete article you can watch the below 5 minute youtube video.

 

 


Step1:- Create project

Create a new project by selecting the MVC 2 empty web application template as shown in the below figure.

 

 

 

Once you click ok, you have a readymade structure with appropriate folders where you can add controllers, models and views.

 

 

Step 2:- Add controller

So let’s go and add a new controller as shown in the below figure.



 

 

 

Once you add the new controller you should see some kind of code snippet as shown in the below snippet.

 

 

 public class Default1Controller : Controller { // // GET: /Default1/ public ActionResult Index() { return View(); } }

Step 3:- Add View

 

Now that we have the controller we need to go and add the view. So click on the Index function which is present in the control and click on add view menu as shown in the below figure.

The add view pops up a modal box to enter view name which will be invoked when this controller is called as shown in the figure below. For now keep the view name same as the controller name and also uncheck the master page check box.

 

 

 

 

Once you click on the ok button of the view, you should see a simple ASPX page with the below HTML code snippet. In the below HTML code snippet I have added “This is my first MVC application”.

 

 

 <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Index</title> </head> <body> <div> This is my first MVC application </div> </body> </html>

Step 4:- Run the application

 

If you do a CNTRL + F5 you should see a error as shown in the below figure. This error is obvious because we have not invoked the appropriate controller / action.

 

 

 

 

If you append the proper controller on the URL you should be able to see the proper view.

 

 

 

So what’s in the next Lab?

Now that we have created a simple MVC hello world, it’s time to see how we can pass data from controllers to views. The first hit comes to the controller which will load your business objects or model and you would like to transfer these objects to the view to display them.

 

Lab2:- Passing data between controllers and views

 

The controller gets the first hit and loads the model. Most of the time we would like to pass the model to the view for display purpose.
As an ASP.NET developer your choice would be to use session variables, view state or some other ASP.NET session management object.

The problem with using ASP.NET session or view state object is the scope. ASP.NET session objects have session scope and view state has page scope. For MVC we would like to see scope limited to controller and the view. In other words we would like to maintain data when the hit comes to controller and reaches the view and after that the scope of the data should expire.

That’s where the new session management technique has been introduced in ASP.NET MVC framework i.e. ViewData.


Video demonstration for Lab 2

 

Below is a simple youtube video which demonstrates the lab for view data. In this video we will see how we can share data between controller and the view using view data. So we will create a simple controller, record the current data in a view data variable and then display the same in the view using the percentage tag.

 




 


Step1:- Create project and set view data

So the first step is to create a project and a controller. In the controller set the viewdata variable as shown in the below code snippet and kick of the view.

 public class DisplayTimeController : Controller { // // GET: /DisplayTime/ public ActionResult Index() { ViewData["CurrentTime"] = DateTime.Now.ToString(); return View(); } } 


Step 2:- Display view data in the view.


The next thing is to display data in the view by using the percentage tag. One important point to note is the view does not have a behind code. So to display the view we need to use the <%: tag in the aspx page as shown in the below code snippet.

 <body> <div> <%: ViewData["CurrentTime"] %> </div> </body> 


So what’s in the next Lab?

So now that we know how to pass data using view data, the next lab is to create a simple model and see all the 3 MVC entities (i.e. model, view and controller) in action.

Lab 3:- Creating a simple model using MVC

In this lab we will create a simple customer model, flourish the same with some data and display the same in a view.

Video demonstration for Lab 3

Below is a video demonstration for the same.

 

Step1:- Create a simple class file

The first step is to create a simple customer model which is nothing but a class with 3 properties code, name and amount. Create a simple MVC project, right click on the model folder and click on add new item as shown in the below figure.

From the templates select a simple class and name it as customer.

Create the class with 3 properties as shown in the below the code snippet.

 public class Customer { private string _Code; private string _Name; private double _Amount; public string Code { set { _Code = value; } get { return _Code; } } public string Name { get { return _Name; } set { _Name = value; } } public double Amount { set { _Amount = value; } get { return _Amount; } } } 



Step2:- Define the controller with action

The next step is to add the controller and create a simple action display customer as shown in the below code snippet. Import the model namespace in the controller class. In the action we created the object of the customer class, flourished with some data and passed the same to a view named as “DisplayCustomer”

 public class CustomerController : Controller { ….. …. public ViewResult DisplayCustomer() { Customer objCustomer = new Customer(); objCustomer.Id = 12; objCustomer.CustomerCode = "1001"; objCustomer.Amount = 90.34; return View("DisplayCustomer",objCustomer); } } 


Step3:- Create strongly typed view using the class


We need to now join the points of MVC by creating views. So right click on the view folder and click add view. You should see a drop down as shown in the below figure. Give a view name, check create a strongly typed view and bind this view to the customer class using the dropdown as shown in the below figure.

The advantage of creating a strong typed view is you can now get the properties of class in the view by typing the model and “.” as shown in the below figure.

Below is the view code which displays the customer property value. We have also put an if condition which displays the customer as privileged customer if above 100 and normal customer if below 100.

 <body> <div> The customer id is <%= Model.Id %> <br /> The customer Code is <%= Model.CustomerCode %> <br /> <% if (Model.Amount > 100) {%> This is a priveleged customer <% } else{ %> This is a normal customer <%} %> </div> </body> 

 

Step 4 :- Run your application

Now the “D” thing, hit cntrl + f5 and pat yourself for one more lab success.

 

So what’s in the next Lab?

In this sample we flourished the customer object from within the controller, in the next lab we will take data from an input view and display the same. In other words we will see how to create data entry screens for accepting data from views.


Lab 4:- Creating simple MVC data entry screen


Every project small or big needs data entry screens. In this lab we will create a simple customer data entry screen as shown in the below figure using MVC template.

As soon as the end user enters details and submits data it redirects to a screen as shown below. If he entered amount is less than 100 it displays normal customer or else it displays privileged customer.

 

Video demonstration for Lab 4

Below is a simple video demonstration for this lab.





 

Step1:- Creating your data entry ASPX page

The first step is to create the data entry page using the simple HTML form action tag as shown in the below code snippet. The most important point to note in the below code snippet is that the action is pointing to the controller action i.e ‘DisplayCustomer’.

 <form action="DisplayCustomer" method="post"> Enter customer id :- <input type="text" name="Id" /> <br /> Enter customer code :- <input type="text" name="CustomerCode" /><br /> Enter customer Amount :-<input type="text" name="Amount" /><br /> <input type="submit" value="Submit customer data" /> </form> 

Step2:- Creating the controller


The above defined form action will post to the controller class and on the function “DisplayCustomer”. So we need to get the data from the HTML controls, flourish the object and send the object to the view.

Below is the code snippet of displaycustomer which flourishes the customer object by collecting data from request.form and sends the object to the view ‘displaycustomer.

 public class CustomerController : Controller { ….. …. [HttpPost] public ViewResult DisplayCustomer() { Customer objCustomer = new Customer(); objCustomer.Id = Convert.ToInt16(Request.Form["Id"].ToString()); objCustomer.CustomerCode = Request.Form["Id"].ToString(); objCustomer.Amount = Convert.ToDouble(Request.Form["Amount"].ToString()); ; return View("DisplayCustomer", objCustomer); } } 


Step3:- Create the view to display the customer object


The next step is to create the “DisplayCustomer” view.So right click on the view folder and click add view. You should see a drop down as shown in the below figure. Give a view name, check create a strongly typed view and bind this view to the customer class using the dropdown as shown in the below figure.


The advantage of creating a strong typed view is you can now get the properties of class in the view by typing the model and “.” as shown in the below figure.

Below is the view code which displays the customer property value. We have also put an if condition which displays the customer as privileged customer if above 100 and normal customer if below 100.

 <body> <div> The customer id is <%= Model.Id %> <br /> The customer Code is <%= Model.CustomerCode %> <br /> <% if (Model.Amount > 100) {%> This is a priveleged customer <% } else{ %> This is a normal customer <%} %> </div> </body> 

Step 4:- Finally run the project


Final step is to run the project and see the output.

You should be also able to test above 100 and below 100 scenarios

 

So what’s in the next Lab?


In this lab we created a simple data entry screen which helped us flourish the customer object. This customer object was then passed to the view for display.
If you closely watch the current lab we have done lot of coding i.e. creating the HTML screens , flourishing the object etc. It would be great if there was some kind of automation. In the next lab we see how HTML helper classes help to minimize many of these manual coding and thus increasing productivity.

Lab 5:- using HTML helper to create views faster


In our previous lab we created a simple customer data entry screen. We completed the lab successfully but with two big problems:-


• The complete HTML code was written manually. In other words, less productive. It’s like going back to dark ages where developers used to write HTML tags in notepad.

 <form action="DisplayCustomer" method="post"> Enter customer id :- <input type="text" name="Id" /> <br /> Enter customer code :- <input type="text" name="CustomerCode" /><br /> Enter customer Amount :-<input type="text" name="Amount" /><br /> <input type="submit" value="Submit customer data" /> </form> 


• Added to it lot of manual code was also written in the controller to flourish the object and send data to the MVC view.

 public class CustomerController : Controller { ….. …. [HttpPost] public ViewResult DisplayCustomer() { Customer objCustomer = new Customer(); objCustomer.Id = Convert.ToInt16(Request.Form["Id"].ToString()); objCustomer.CustomerCode = Request.Form["Id"].ToString(); objCustomer.Amount = Convert.ToDouble(Request.Form["Amount"].ToString()); ; return View("DisplayCustomer", objCustomer); } } 

In this lab we will see how to use MVC HTML helper classes to minimize the above manual code and increase productivity


Step 1:- Create the Customer class

Create a simple customer class , please refer Lab 5 for the same.

Step2:- Creating the input HTML form using helper classes

HTML helper classes have readymade functions by which you can create HTML controls with ease. Go to any MVC view and see the intellisense for HTML helper class you should see something as shown in the below figure.

By using HTML helper class you can create any HTML control like textbox, labels, list box etc just by invoking the appropriate function.

In order to create the form tag for HTML we need to use “Html.BeginForm” , below goes the code snippet for the same.

 <% using (Html.BeginForm("DisplayCustomer","Customer",FormMethod.Post)) {%> -- HTML input fields will go here <%} %> 

The above code will generate the below HTML

 <form action="DisplayCustomer" method="post"> ….. ….. </form> 


The HTML helper “beginform” takes three input parameters action name (Method inside the controller), controller name (actual controller name) and HTTP posting methodology (Post or GET).



If you want to create a text box, simply use the “TextBox” function of html helper class as shown in the below code. In this way you can create any HTML controls using the HTML helper class functions.

 Enter customer id :- <%= Html.TextBox("Id",Model)%> <br /> 


The above code snippet will generate the below HTML code.

 Enter customer id :- <input type="text" name="Id" /> <br /> 

To create a data entry screen like the one shown below we need to the use the below code snippet.

 <% using (Html.BeginForm("DisplayCustomer","Customer",FormMethod.Post)) { %> Enter customer id :- <%= Html.TextBox("Id",Model)%> <br /> Enter customer code :- <%= Html.TextBox("CustomerCode",Model) %><br /> Enter customer Amount :- <%= Html.TextBox("Amount",Model) %><br /> <input type="submit" value="Submit customer data" /> <%} %> 

Step 3:- Create a strong typed view by using the customer class


So once you have created the view using the HTML helper classes it’s time to attach the customer class with view , please refer lab 5 for the same.

Step4:- Creating the controller class.


The final thing is the controller code. The controller code now becomes very simple. The customer object will be auto flourished as we have used the HTML helper classes. You will create the controller class as we did in Lab 4 but we do not need to write any kind of code for connecting the HTML screens with controller, it’s all hidden and automated.

 [HttpPost] public ActionResult DisplayCustomer(Customer obj) { return View(obj); } 

Enjoy your output for different condition of customer amount entered.


So have a toast of beer for completing your first day of MVC labs.

 

What’s for the second day?

In the next labs we will talk about URL routing, ease of MVC unit testing, MVC Controller attributes and lot more. The next lab will bit more advanced as compared to the first day, so take rest and I need to work hard to get you the second day labs.

 

Share this post

Repost 0
Published by Shivprasad koirala
write a comment

comments

Important .NET and C# interview questions and answers

.Net interview questions: - Explain why it is not preferred to use finalize for clean up?

.Net interview questions: - Show the five levels in CMMI?

.NET interview questions and answers: – Which is the best place to store connection string in .NET projects?

C# interview questions and answers: – Explain the use of Icomparable in c#?

C# interview questions: - How can we check which rows have changed since dataset was loaded?

C# interview questions and answers: - Can you write a simple c# code to display Fibonacci series?

.NET interview questions and answers: - What is difference betweenIcomparable VS Icomparer ?

C# and .NET interview question: -What is short circuiting in C#?

C# and .NET interview question: - What are symmetric and asymmetric algorithms?

Important c# and .NET interview question on object pooling and Gridview events?

.NETinterview questions and answers: – Will the finally run in this code?

How to prepare for c# and .NETinterviews?

C# and .NET Interview questions: - What is Thread.Join () in threading?

.NET Interview questions and answers: -What is serialization and deserialization in .NET?

C# and .NET interview question: - What is hashing?

c# and .NET interview question:- what connects dataset and data source ?

.Net interview questions and answers: - What is the difference between “Web.config” and “Machine.Config”?

.NET interview questions and answers: - What is TPL?

.NET Interview questions and answers: -What are different access modifiers?

.NET and c# Interview Question and answers: – If we want to update interface with new methods, what is the best practice?

 MVC ( Model view controller) interview questions and answers      

ASP.NET Application and Page Life Cycle 

12 Important FAQ’s on VSTS Testing (Unit testing, load testing, automated testing, database testing and code coverage) 

 6 important use of Partial/Mock testing

6 important uses of Delegates and Events

7 Simple Steps to Run Your First Azure Blob Program

8 Steps to Create Workflows using SharePoint Designer

Azure FAQ Part 1

C# Code Reviews using StyleCop – Detailed Article

Four real world uses of Partial classes and Partial methods

SharePoint Quick Start FAQ Part 1

SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows

SharePoint Workflow Basics

 

 

 

 

MVC Interview questions videos

Viewdata,viewbag,tempdata

 

MVC asynch controllers

What is View Model in ASP.NET MVC?



ADO.NET interview questions videos



Explain ADO.NET Connection pooling

 

 

Windows Phone Application Questions Videos

 

How to create a simple windows phone application ?

 

 

MVC Interview questions and answers Article

 

(Model view controller)MVC Interview questions and answers

MVC interview questions with answers video: – What is Web API how to implement the same?

ASP.Net MVC  4 interview questions with answers: - What is Bundling and minification in Model view controller ?

MVC interview questions with answers :- Is it possible to return values instead of Actionresults?

MVC interview questions with answers :- What are the actionresults available in MVC?

MVC interview questions with answers:-Html.PartialvsHtml.RenderPartialvsHtml.RenderPage in MVC

MVC ASP.NET INTERVIEW QUESTIONS WITH ANSWERS :- WHAT IS THE DIFFERENCE BETWEEN VIEWSTATE VS VIEWDATA ?

MVC vs ASP.NET ( MVC Interview question with answers )?

How can we detect that a MVC controller is called by POST or GET ? ( ASP.NET MVC Interview questions with answers)

What are the different ways by which you will get Form Data in controller? ( MVC Interview questions with answers)

What is the difference between Presenter and Controller in MVC?(MVC interview questions with answers)

Learn MVC (Model view controller) Step by Step in 7 days – Day 4

MVC Interview questions and answers PDF

MVC interview questions with answers

ActionResult vs. View() vs. ViewResult :- MVC interview questions with answers

Explain Areas in MVC?( MVC interview questions with answers)

Can you explain the purpose of ViewModel in MVC?( ASP.NET MVC Interview questions with answers)

ASP.NET MVC interview questions: - What are Filters in MVC?

What are areas in MVC?( MVC Interview questions with answers)

Explain the concept of View Model in MVC?

Exception Handling in MVC

Explain MVC application life cycle?


100 MVC Interview question PDF download released , Enjoy


Learn Microsoft Business intelligence step by step – Day 1


Can you create TempBag just like ViewBag?( MVC Interview questions)


MVC Unit Testing Unleashed

MVC and .NET learning tutorials for components of MVC and how do you perform unit testing in MVC?

Explain MVC model binders ? ( ASP.NET MVC interview questions)

Explain the difference between layout and master pages ? (MVC Razor interview questions)

Advantages of ViewModel in MVC(Model View Controller)

Difference Between ViewResult() and ActionResult() in MVC ?

What is the difference between each version of MVC 2, 3, 4, 5 and 6? (MVC Interview Questions)

Learn ASP.NET MVC 5 Step by Step in 30 days – Day 1

Can we overload MVC controller action methods ? (MVC Polymorphism) 

Can we overload Actions / Controllers in MVC? (MVC Interview questions)

 


WCF Interview questions videos

 

overloading in WCF

WCF fault exceptions ?

 

 

 

 

WPF Interview question with answers videos

 

Why WPF and compare WPF with Winforms ?

 

 

C# Interview Questions & Answers Article

 

12 Important FAQ’s on VSTS Testing (Unit testing, load testing, automated testing, database testing and code coverage)

6 important use of Partial/Mock testing

6 important uses of Delegates and Events

7 Simple Steps to Run Your First Azure Blob Program

8 Steps to Create Workflows using SharePoint Designer

Azure FAQ Part 1

C# Code Reviews using StyleCop – Detailed Article

Four real world uses of Partial classes and Partial methods

SharePoint Quick Start FAQ Part 1

SharePoint Quick Start FAQ Part 6 – Workflows, Workflows and Workflows

SharePoint Workflow Basics

C# (Csharp) interview questions and answers: – What are indexers in .NET?

C# OOP interview questions and answers: - I do not want to implement all the interface methods?

C# design pattern (UNIT of Work Design Pattern)

C# design pattern interview questions – What is Dependency injection ?

C# interview questions and answers: - What is the difference between “==” and .Equals()?

How questions are asked in c# interviews?

C# design pattern interview question: - DI vs IOC

8 important C# Interview questions on IL code, JIT, CLR, CTS, CLS and CAS

What is the difference between Reflection and Dynamic in C#?

C# and .NET interview question: – When should we use Structure as compared to classes
?

C# REST interview questions with answers asked in Polaris Hydrebad

c# threading interview questions :- Parallel.ForEach vs Task.Factory.StartNew

C# circular dependency interview questions with answers.

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

C# and .NET interview questions with answers: - How can we mark a method as deprecated?

C# INTERVIEW QUESTIONS WITH ANSWERS: - HOW TO ASSIGN MULTILINE STRING IN VISUAL STUDIO?

What is cyclomatic complexity (C# testing interview questions with answers)?

Define code coverage? (C# unit testing interview questions with answers)

Can you talk about Abstraction and Encapsulation in detail ? ( .NET, c# and OOP interview questions with answers )

Can you explain a practical example of virtual and Override? ( C# OOP interview questions with answers )

Can you explain class and object in real time scenario? ( C# and .NET OOP Interview questions with answers)

What is code digger ? ( C# visual studio interview questions with answers)

C# Lazy loading interview questions with answers

What is eager loading in c# ( C# eager loading interview questions with answers)?

Can you explain the term concurrency? (C# Interview questions with answers)

10 important C# Constructor and destructor interview questions

3 important c# Partial class interview questions with answers

Change Functionality without changing function( C# Architecture interview question with answers)?

What is ENUM and what are the benefits of using it (ENUM C# Interview Question 1)?

How can we loop through ENUM values( C# ENUM Interview questions with answers)?

What is the difference between Connection Timeout and Command Timeout?( C# ADO.NET Interview questions with answers)

How you differentiate Shadowing with Overriding? (C# overriding interview questions)

C# date and time interview question with answers

Explain the difference between early binding and late binding? ( C# interview questions with answers)

How can we restrict types in generics ?( C# generic interview questions)

What are generics, Delegates and Generic delegates ( C# interview questions)?

How can we convert JSON string in to c# object?(  C# JSON interview questions)

C# and .NET interview questions asked in TCSwalkin.

C# and .NET interview questions on Coalescing operator.

String vs string ( C# interview questions with answers)

Explain SOLID principles (C# Architecture interview questions)?

C# and .NET interview questions around Read only and Constant

C# Architecture interview questions with answers

C# Mock testing interview questions and answers: – What is Mock testing and how can we implement Mocking?

Write a simple regex for email validation? (C# interview questions with answers)


C#.NET interview questions: - What is the use of “Yield” keyword? Mention atleast one practical scenario where it can be used?

C#.NET interview questions: - What is the difference between Build Vs Rebuild Vs Clean solution menu? What is the difference “Rebuild” and if you do “Clean” + “Build”?

C# and .NET interview questions around JIT and NGEN


What is the difference between throw vs throw ex ?( C# Interview questions with answers)

C#/.NET interview questions: - What are the steps included to get a collection of records from database in C#?


Learn C# in Hindi video tutorials


QuestPond’s real life examples on Extension methods and nullable types in C#.NET


Why Microsoft has partial classes and Java does not?

 

 

 

WCF INTERVIEW QUESTIONS AND ANSWERS ARTICLE

 

 

WCF INTERVIEW QUESTIONS AND ANSWERS: - WHAT IS THE DIFFERENCE BETWEEN SERVICE ENDPOINT AND CLIENT ENDPOINT

 

WCF INTERVIEW QUESTIONS WITH ANSWERS: - WCF REST VS. WEB API

 

WCF INTERVIEW QUESTIONS WITH ANSWERS :- CAN WE HAVE METHOD OVERLOADING WHILE DEFINING WCF SERVICE OPERATIONS ?

 

WCF INTERVIEW QUESTIONS WITH ANSWERS :- WHAT IS DATACONTRACTSERIALIZER AND HOW IT’S DIFFERENT FROM XMLSERIALIZER 

What is SOA and what is WCF? ( WCF interview questions with answers)

Six important WCF interview questions with answers

6 important WCF Instancing interview questions with answers

WCF Service metadata interview questions with answers

7 WCF SOA interview questions with answers

What are the various ways of consuming WCF services?(WCF C# interview questions with answers)

What is the difference between Serialization and Encoding in WCF?( WCF interview questions with answers)

Why returning dataset or data table from WCF service is not a good practice?(WCF service interview questions with answers)

WCF transaction interview questions: - How transaction works in WCF?

WCF Transaction interview questions.

.NET WCF(Windows Communication Foundation) interview questions: - Distinguish between Web Services and Remoting | WCF and Web services

WCF interview questions: - What exactly do you mean by Single in WCF instancing? How to set and what is by default set value of instance context mode?

Explain WCF Duplex services? ( WCF Interview questions)

QuestPond: Interview Questions and Answers on learning WCF

WCF Interview Questions: - What are the different ways of doing WCF concurrency and WCF instancing?

QuestPond: Interview Questions and Answers on learning WCF (Windows Communication Foundation)

QuestPond: Interview Questions and Answers on learning WCF (Windows Communication Foundation)

QuestPond: Interview Questions and Answers on WCF(Windows Communication Foundation)

QuestPond: Interview Questions and Answers on learning WCF (Windows Communication Foundation)

QuestPond’s Interview Questions & Answers on learning data contract serializer and XML serializer

QuestPond’s Interview Questions & Answers on learning serialization events

QuestPond’s Interview Questions & Answers on learning WCF(Windows Communication Foundation)

QuestPond’s Interview Questions & Answers on WCF(Windows Communication Foundation)


QuestPond’s Interview Questions & Answers on WCF(Windows Communication Foundation)

QuestPond’s Interview Questions & Answers on WCF (Windows Communication Foundation)


QuestPond’s Interview Questions & Answers on WCF (Windows Communication Foundation)

 

 

 

WPF Interview Questions And Answers Article

 

 

6 IMPORTANT WPF AND SILVERLIGHT MULTI-THREADING INTERVIEW QUESTIONS WITH ANSWERS

 

C# WPF INTERVIEW QUESTIONS::- WHAT ARE DEPENDENCY PROPERTIES ?

 

WPF INTERVIEW QUESTIONS WITH ANSWERS: – WHAT ARE WPF CONVERTERS?

 

WPF INTERVIEW QUESTIONS ON EVENTS (TUNNELING, BUBBLING AND DIRECT)

 

What are the advantages of using WPF ( WPF interview questions with answers)?

 

Explain WPF bindings?( .Net WPF Binding interview questions)

 

WPF Interview questions with answers :-What is XAML in WPF and why do we need it?

 

What are the different kinds of controls in WPF?(C# WPF Interview questions with answers)

 

Can you explain the complete WPF object hierarchy?(WPF Interview questions with answers)

How does “UpdateSourceTrigger” affect bindings?( C# WPF interview questions with answers)

WPF Interview questions :- Which are the different namespaces and classes in WPF ?

What are resources in WPF? (C# WPF Interview questions with answers)

Explain multi binding and multivalue converters? (.NET WPF  Interview questions with answers)

Explain the difference between static and dynamicresource? (.NET WPF interview questions)

18 important WPF interview questions asked in WPF interviews.

.NET WPF(Windows Presentation Foundation) interview questions: - What is WPF? What are the advantages of WPF over Winforms?

Explain WPF relative binding / relative resource? (.NET WPF Interview questions with answers)

Explain Ancestor relative source binding in WPF ? ( WPF Interview questions with answers)

Explain the need of binding and commands?(WPF Interview questions)

Can you explain WPF command with an example? ( WPF Interview questions with answers)

Explain the need of “INotifyPropertyChanged” interface? ( C# WPF Interview questions with answers)

What is MVVM? (WPF MVVM Interview questions)

What is the importance of command and bindings in MVVM pattern? ( WPF MVVM Interview questions)

What is the difference between MVVM and 3 layer architecture? ( WPF  MVVM Interview questions with answers)

Explain delegate command? (WPF MVVM interview questions)

WPF Interview questions with answers

Explain WPF styles?(C# WPF Interview questions with answers)

Explain Multitrigger concept in WPF?( C# WPF Interview questions with answers)

How are WPF observable collections different from simple .NET collections? (.NET WPF Interview questions)

What is the difference between control templates and data templates? ( .NET WPF Interview questions)

What are various ways of doing alignment in WPF?( WPF Interview questions with answers)

 

Algorithm Interview Questions


Algorithm interview questions and answers: – Can you write code for bubble sort algorithm?

Algorithm interview questions and answers: – What is inserted sort algorithm?

SQL INTERVIEW QUESTIONS & ANSWERS ARTICLE

 

SQL Server Interview Questions & Answers Article

SQL Server interview questions and answers: - What is HID data type in SQL Server ?

SQL Server interview questions with answers: – How to get the top record without using max, top and order by keyword?

SQL Server interview questions with answers :- If you wish to store financial values which SQL Server data type is more suitable ?

SQL Server interview questions and answers: – What is the difference between Candidate Key, Primary Key, and Alternate Key

SQL Server interview questions with answers :- What are Indexes in Sql Server?

How to sort interactively using SSRS? (SQL Server reporting services interview questions)

How to do conditional formatting in SSRS? (SQL Server reporting services interview questions with answers)

WHAT IS NORMALIZATION AND EXPLAIN 1NF 2NF AND 3NF IN SIMPLE WORDS? SQL SERVER INTERVIEW QUESTIONS WITH ANSWERS

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

 

When you will use inner join and when you will use outer join? SQL Server interview questions with answers

 

Do you know anything about Temporary procedures in SQL?( SQL Server interview questions with answers)

 

4 SQL Server interview questions with answers on TempTb

 

Are full outer join and Cross join are same? ( SQL Server interview questions with answers)

 

Delete duplicate records: - SQL Server interview questions with answers

 

4 most asked  SQL queries during SQL Serverinterview’s

 

How Temporary tables are different from normal tables and what are its types ?( SQL Server interview questions with answers)

 

SQL Server interview Questions on JOIN’s

 

SQL Server interview questions: - How can you increase SQL performance?

 

SQL Server interview questions: - What problem you face if locking is not implemented?

 

Can we insert NULL’s in to UNIQUE key ? ( SQL Server  interview questions with answers)

 

Explain Normalization?(SQL Server Interview questions with answers)

Temp variablesVS Temp tables(SQL Server interview questions)

 


 




.NET INTERVIEW QUESTIONS & ANSWERS ARTICLE

 

.NET interview questions and answers: - How to reverse a string in .NET ( DotNet)?

.NET interview questions and answers: - What is the use of Click Once?

.NET interview questions and answers: - Will the below codes create new instances?

C# and .NET interview questions with answers – What is Nuget?

Dependency injection (DI) VS Inversion of Control (IOC)

.NET interview questions with answers: - What is the difference between Reflection and Dynamic?

Five Great .NET Framework 4.5 Features

ASP.NET MVC 4 interview questions with answers: - What is the use of “AllowHTML” and “ValidateInput” attributes?

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

.NET interview questions with answers: – Can we use events without delegates ?

.Net Interview question Edition 6 is available now.

.NET interview questions with answers: – What’s the difference between catch with parameter and catch without parameter?

.NET interview questions : - What is the use and difference between “IS” and “AS” keyword?

.NET interview questions with answers: - Build solution VS Rebuild solution VS Clean solution

HTML 5 interview questions with answers for LocalStorage and SessionStorage

.NET 4.0 interview questions with answers: – What are code contracts?

What are portable class libraries? ( .NET interview questions with answers)

How to loop through ENUM using C# (.NET interview questions with answers)?

What are transactions in C#? (.NET interview questions with answers)

What are ACID Properties( .NET Interview questions with answers)?

.NET interview questions: – What are the areas that need to be concentrated for senior(9+ years experience)persons in .NET technologies?

.NET interview questions: - Explain real time scenarios in Factory Pattern, Abstract Pattern, Singleton, WCF and REST services

What is the difference between IS A and Can a Relationship?( .NET Interview questions with answers)

What is the use of ENUM Flags(.NET Enum Interview question 2)?

What is the difference between .Net,C#, Asp.net, Asp.net Web Forms and Asp.net MVC and MVC?( C# and ASP.NET Interview questions)

ADO.NET interview questions: - Explain in detail the fundamental of connection pooling?

.NET interview questions: – Can you explain generics in .NET?

What are Properties and methods ? ( .NET OOP Interview questions with answers)

What’s the first step you take for implementing any of Design Pattern?( .NET  Design pattern interview questions with answers)

.NET interview questions: - What are different types of JIT?

ADO.NET Interview Question: - What are the major differences between classic ADO and ADO.NET?

.NET interview questions: – What is the difference between Reflection and Dynamic?

What is the Use of interfaces?( .NET Interview questions with answers)

.NET interview questions: - What role did you play in your project and company?

Visual studio 2012 Fakes

.NET interview questions: - So how can we clean unmanaged objects and also maintain performance?

ADO.NET Interview Questions: - What are basic methods of Data adapter?

.NET interview questions: - What are system level exceptions and application level exceptions?

.NET interview questions: - What is UML and which are the important diagrams?

.NET interview questions: - What is time out support in regex (regular expression)?

.NET interview questions: - How can we improve performance of .NET?

.NET interview questions: - Can you explain the concept of “Short Circuiting”?

.NET interview questions: - Can you explain Forms authentication in detail?

What is the difference between VAR and Dynamic keyword? ( .NET Interview questions with answers)

.NET interview questions: - What are similarities and difference between Class and structure?

Can you compare String.IsNullOrEmpty vs String.IsNullOrWhiteSpace ? ( .Net Interview questions with answers)

.NET interview questions: - Distinguish between Reflection and Dynamic?

.NET interview questions: - In which scenarios we can use serialization and when to use what binary serialization or XML serialization?

.NET interview questions: - Are there any readymade objects in .NET by which we can implement Lazy loading?

.NET interview questions: - What are different access modifiers?

ADO.NET interview questions: - Explain in detail the fundamental of connection pooling how to enable and disable connection pooling?

ADO.NET interview questions: - What is the namespace in which .NET has the data functionality class?

ADO.NET interview questions: - What are the different components in ADO.NET?

ADO.NET interview questions: - Show difference between “Optimistic” and “Pessimistic” locking and how many ways are there to implement optimistic locking in ADO.NET?

.NET interview questions: - Does code contract only do dynamic checks?

ADO.NET interview questions: - How can we fire a simple SQL Statement using ADO.NET?

.NET interview questions: - What basic steps are needed to display a simple report in crystal?

ADO.NET interview questions: - What are basic methods of Data adapter and mention the use of data adapter?

.NET interview questions: - What is UML? How many types of diagrams are there in UML?

.Net Interview Questions - What is MVC, MVP and MVVM pattern?

.NET interview questions: - How can you define a property read only for external world and writable in the same assembly?

Explain the implicit and explicit conversion of data types with examples?( .NET interview questions on data type)

.NET interview questions: - What is Reflection its implementation and practical uses?

What is downcasting and upcasting? (.NET interview questions with answers)

.NET interview questions: - How to decide on the design consideration to take a Data grid, data list or repeater?

.NET interview questions: - If we want to update interface with new methods, what is the best practice?

.NET interview questions: - How does selection sort algorithm works?

XML(.NET) interview questions: - What is XML?

.NET Interview questions: - If a validation is very complex what will you do?

.NET interview questions: - How can we stop the class from further inheriting?

XML (.NET) Interview questions :- Explain simple Walk through of XmlReader.

.NET interview questions : - How can we improve performance of .NET and show the difference between .NET 1.X, 2.0, 3.0, 3.5 and 4.0?

How to convert string to ENUM value ?( .NET interview questions with answers)

.NET architecture interview questions series: - What is mean by modeling language?

.NET architecture interview questions : - What are benefits and Limitation of using Viewstate, hidden frames and Cookies?

.NET interview questions: - What is GAC (Global Assembly Cache)?

.NET interview questions: - Explain Nuget?

.NET Testing interview questions: - What is the difference between Unit testing, Assembly testing and Regression testing?


.NET interview questions: - What is Code Access Security (CAS) and how does it work? Is CAS supported in .NET 4.0?


.NET interview questions: - What are the advantages /disadvantages of lazy loading?


.NET interview questions: - What is the use of DEBUG directive?


.NET testing interview questions: - What is Mock testing and how to implement it?


.NET interview questions: - What is the difference between DEBUG and Release?


.NET testing interview questions: - How can we UNIT test private methods using VSTS? Is it good to practice to UNIT test Private methods?


Explain 3 layer architecture ( .NET Interview questions)?


.NET interview questions : - What is a delegate and how can we create a delegate? What is a multicast delegate?


ADO.NET interview questions: - How to add/remove row is in “Data Table” object of “Dataset”? How to load multiple tables in a Dataset & adding relation between tables in a Dataset?


What is the difference between Array, ArrayList and List?( .Net Interview questions)

.NET interview questions: - How to implement DTC in .NET?
.NET interview questions: - What is an Interface and what are abstract classes

.NET interview questions: - Interface vs. abstract class

.NET interview questions: - How to implement practically Lazy loading in .NET?


.NET interview questions: - How can we handle exceptions in .NET? What if we do not catch the exception?

.NET interview questions based on Projects.


.NET interview questions: - What is shadowing? What is the difference between Shadowing and Overriding?

.NET interview questions: - All about Design Patterns in .NET


.NET interview questions: - How can we improve performance of .NET/ASP.NET/SQL Server?

.NET interview questions: - What benefits does sealed keyword provide?


.NET Architecture UML interview question


.NET interview questions: - How to maintain performance and can clean unmanaged objects?


.NET interview questions: - Explain ENUM and its benefits? What is the use of Flagsin ENUM?

.NET interview questions: - How to create a windows service using .NET?

.NET interview questions: - Explain in details about Indexer and can we have static indexer in C#?

.NET interview questions: - What is the difference between arraylist and list? Are Arraylist faster or Arrays?

.NET interview questions: - What is Native Image Generator (Ngen.exe)? Does NGEN.EXE always improve performance?

.NET OOPS interview questions: - What is OOP? What are different properties provided by Object-oriented systems?

.NET OOPS interview questions: - How abstract with only abstract method is it different from interfaces? Also mention best practice to update interface with new methods?

.NET interview questions: - What is the difference between delegate and events? Can we have return type, access modifiers and shared events?

.NET interview questions: - What is Manifest? Where is the version information stored of an assembly? Is versioning applicable to private assemblies?

.NET Generics interview questions: - Explain Generics and concept of Generic Collection in .NET?

How to learn .NET: - In parent-child relationship which constructor will fire first and in which instances you will declare a constructor private?

Basics of .NET and learning tutorials on CTS and CLS


Online resource to learn .NET on Reflection and Dynamic

Online guide to learn .NET for Object initializer in C#?

QuestPond for Freshers on IL code, JIT, CLR, CTS, CLS and CAS

QuestPond: Interview Questions and Answers on AJAX and how does it help?



ASP.NET Interview Questions & Answers Article










MVC Interview Questions And Answers Article

 

(MODEL VIEW CONTROLLER)MVC INTERVIEW QUESTIONS AND ANSWERS

 

MVC INTERVIEW QUESTIONS WITH ANSWERS VIDEO: – WHAT IS WEB API HOW TO IMPLEMENT THE SAME?

 

ASP.NET MVC  4 INTERVIEW QUESTIONS WITH ANSWERS: - WHAT IS BUNDLING AND MINIFICATION IN MODEL VIEW CONTROLLER ?

 

MVC INTERVIEW QUESTIONS WITH ANSWERS :- IS IT POSSIBLE TO RETURN VALUES INSTEAD OF ACTIONRESULTS?

 

MVC INTERVIEW QUESTIONS WITH ANSWERS :- WHAT ARE THE ACTIONRESULTS AVAILABLE IN MVC?

 

MVC INTERVIEW QUESTIONS WITH ANSWERS:-HTML.PARTIALVSHTML.RENDERPARTIALVSHTML.RENDERPAGE IN MVC

MVC VS ASP.NET ( MVC INTERVIEW QUESTION WITH ANSWERS )?

 

HOW CAN WE DETECT THAT A MVC CONTROLLER IS CALLED BY POST OR GET ? ( ASP.NET MVC INTERVIEW QUESTIONS WITH ANSWERS)

 

WHAT ARE THE DIFFERENT WAYS BY WHICH YOU WILL GET FORM DATA IN CONTROLLER? ( MVC INTERVIEW QUESTIONS WITH ANSWERS)

 

WHAT IS THE DIFFERENCE BETWEEN PRESENTER AND CONTROLLER IN MVC?(MVC INTERVIEW QUESTIONS WITH ANSWERS)

 

LEARN MVC (MODEL VIEW CONTROLLER) STEP BY STEP IN 7 DAYS – DAY 4

 

MVC Interview questions and answers PDF

 

MVC interview questions with answers

 

ActionResult vs. View() vs. ViewResult :- MVC interview questions with answers

Explain Areas in MVC?( MVC interview questions with answers)

 

Can you explain the purpose of ViewModel in MVC?( ASP.NET MVC Interview questions with answers)

ASP.NET MVC interview questions: - What are Filters in MVC?

What are areas in MVC?( MVC Interview questions with answers)

Explain the concept of View Model in MVC? 

Exception Handling in MVC

Explain MVC application life cycle?

100 MVC Interview question PDF download released , Enjoy

How can we use two (multiple) models with a single view?(MVC Interview questions)

MVC HTML.Form vs Ajax.Form – MVC interview questions with answers

Learn Microsoft Business intelligence step by step – Day 1

Can you create TempBag just like ViewBag?( MVC Interview questions)

MVC Unit Testing Unleashed

MVC and .NET learning tutorials for components of MVC and how do you perform unit testing in MVC?

Explain MVC model binders ? ( ASP.NET MVC interview questions)

Explain the difference between layout and master pages ? (MVC Razor interview questions) 


ENTITY FRAMEWORK INTERVIEW QUESTIONS ARTICLE


Windows Workflow Foundation(WWF) interview questions with answers Article

XML Interview Questions With Answers Article


Explain XML,DTD and XSL?(XML interview questions with answers)

HTML 5 Interview questions With Answers Article

HTML 5 interview questions with answers for LocalStorage and SessionStorage

 

How is the page structure of HTML 5 different from HTML 4?( HTML 5 Interview questions with answers)

 

What is datalist in HTML 5 ( ASP.NET HTML interview questions)?

 

What are the different new form element types in HTML 5?( ASP.NET HTML 5 interview questions with answers)

 

What is output element in HTML 5?( ASP.NET HTML 5 interview questions)

 

What is the difference between Canvas and SVG graphics?(ASP.NET HTML 5 interview questions with answers)

 

ASP.NET HTML 5 interview questions on SVG and Canvas

ASP.NET HTML5 interview questions with answers

What are web workers and why do we need them ?( ASP.NET HTML interview questions with answers)

 

Why do we need HTML 5 server-sent events? (ASP.NET HTML interview questions)

How can we add and remove data from local storage?(ASP.NET HTML 5 interview questions)

What is local storage concept in HTML 5? ( ASP.NET HTML 5 interview questions)

What is the difference between local storage and cookies? ( ASP.NET HTML 5 interview questions)

What is WebSQL?( ASP.Net HTML 5 interview questions)

 

What is session storage and how can you create one?( ASP.Net HTML 5 interview questions with answers)

 

What is application cache in HTML5?( ASP.NET HTML 5 interview questions with answers)

ASP.NET HTML 5 Application cache interview questions with answers

 

Explain the term cascading in style sheet ? ( CSS Interview questions)

What is difference between DIV vs SPAN in HTML ?( ASP.Net Interview questions)

HTML 5 Canvas Interview questions: - Canvas in HTML 5.

QuestPond’s interview questions and answers on HTML 5

 

Learn HTML 5 in 3 days – Day 1

 

 

 

Dotnetspider Questions And Answers Article

 

 

What is downcasting and upcasting ? ( .NET interview questions with videos)

 

What is the difference between String vs string? ( C# interview questions) ?

 

 

JAVASCRIPT INTERVIEW QUESTIONS WITH ANSWERS ARTICLE

 


3 IMPORTANT JAVASCRIPT IMPORTANT INTERVIEW QUESTION WITH ANSWERS