You are on page 1of 40

RN REDDY IT SCHOOL

Mr. RN REDDY BANDA

ASP.Net MVC
Interview Question & Answer’s

2nd Floor, Sri Sai Arcade,

Beside Aditya Trade Centre, Ameerpet


Ph: +91 9100920092 , +91 9100940094

ASP.NET MVC Q&A Mr.R.N.Reddy


ASP.NET MVC

1. What is MVC?
 MVC Stands for Model View Controller.

 MVC is a design pattern used to develop the applications.

 MVC comes under Architectural design pattern.

 Ex: Microsoft is using MVC in ASP.Net which can be called as


“ASP.Net MVC".

2. What is Design Pattern?

 Design pattern is a well-defined solution for the problems that occurs


in software development in specific context/situation.

 Design pattern can be used in any technology & any programming


environment.

 Ex: MVC  ASP.NET MVC.


Singleton  WCF.
DAO (Data Access Object) ADO.NET.

3. What is MVC Design Pattern?


 In MVC Design pattern, Application development will be splitting into
three Modules.

1. Model.
2. View.
3. Controller.
ASP.NET MVC Q&A Mr.R.N.Reddy

4. What is the role of Model?


 Model is responsible for Database related logic.

 In MVC application model will communicate with database and return


the results to the controller.

 Model sends the results/status to controller after processing the


database operations.

 In ASP.Net MVC Models are developed using ADO.NET or Entity


Frameworks or Linq.

5. Why is the role of View?


 View is responsible for presentation related logic (UI).

 View will get data from Controller and it prepares output.

 In ASP.Net MVC, views are developed by using following technologies.

1. HTML [Hyper Text Mark-up Language].


2. CSS [Cascading Style Sheets].

3. JavaScript.
4. Angular JS.
5. JQuery.
6. C#.

6. What is the role of Controller?


 Controller is responsible for application execution logic

 Every Request will be received by controller only.

 At the time of processing the request controller will communicate


with model & view based on the request.

 In ASP.Net MVC Controllers are developed by using c#.Net i.e. (.CS


Files).

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 3


ASP.NET MVC Mr.R.N.Reddy

7.Explain the MVC Diagram?

 Controller will receive request from Client, at the time of


processing the request controller will communicate with model &
view based on the request.

 Model will communicate with database and return the results to


the controller if it’s related to Database.

 View will get data from Controller and it prepares output.

8.Write the list of technologies using MVC?

 ASP.NET MVC [DOT NET].


 Spring MVC [JAVA].
 Struts MVC [JAVA].
 Ruby on Rails MVC.
 PHP MVC.
 IPhone OS MVC.

9. What is ASP.Net MVC?


 ASP.Net MVC is a framework used to develop web applications by
using MVC applications.

 In MVC based applications development process will be splitting into


three modules.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 4


ASP.NET MVC Mr.R.N.Reddy

 They were

1. MODEL
2. VIEW.
3. CONTROLLER.

10. Who has designed ASP.Net MVC and When?


 ASP.Net MVC was developed by Scott Guthrie in the year 2007.

11. From which year onwards we are using MVC


in ASP.Net?
 From 2009

12. Write the list of ASP.NET MVC Versions with years?

S.NO ASP.NET MVC Version Year

1 ASP.NET MVC V1.0 2009

2 ASP.NET MVC V2.0 2010

3 ASP.NET MVC V3.0 2011

4 ASP.NET MVC V4.0 2012

5 ASP.NET MVC V5.0 2013

6 ASP.NET MVC V5.2 2014

7 ASP.NET MVC V6.0 2015

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 5


ASP.NET MVC Mr.R.N.Reddy

13. a).Is ASP.NET MVC is a replacement of


ASP.NET WebForm?

 No

b). Is ASP.NET MVC is next generation of


ASP.NET WebForm?

 Yes.

14. Is MVC is a part of DOT NET?


 No, it’s a Design pattern following by ASP.Net developer which can be
called as ASP.Net MVC.

15. Why ASP.NET MVC or What are the advantages of


ASP.NET MVC?
 Because of below 10 advantages we will go for ASP.Net MVC rather
than ASP.Net WebForms.

1. Separation of Code.
2. Loosely Coupled (Less Dependent).
3. Parallel Development
4. Easy to perform unit testing.
5. TDD Support
6. Clean & clear URL’s
7. Improved performance.
8. More controlling over HTML.
9. Added new concepts.
10. Easy to learn and Easy to implement.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 6


ASP.NET MVC Mr.R.N.Reddy

16. What is separation of code in ASP.Net MVC?


 MVC based applications are separating the Model (DB Logic) from
View (presentation Logic).Single application development we can split
into 3 parts.

 Due to this separation of code application can be developed very easily

17. What is loosely coupled in ASP.Net MVC?


 In MVC Based applications views are less dependent on Models. These
two modules (view & Model) are organised by controller, due to this
feature we can easily update the required module without effecting
other Module.

18. What is parallel development in ASP.Net MVC?


 In ASP.Net MVC a team can work on Models and another team can
work on Views, with this parallel application development process will
continue.

 Due to this feature development process becomes faster & easy.

19. What makes ASP.Net MVC to perform easy


unit testing?
 In ASP.Net MVC application development will be divided into three
parts.

 Model  View Controller.

 Because of this we can easily perform the unit testing on particular


module.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 7


ASP.NET MVC Mr.R.N.Reddy

20. What is TDD support ASP.Net MVC?


 TDD Stands for Test Driven Development.

 It’s the latest development technique.

 TDD, tests will provide the guidelines for developers.

 Testers will provide new features/options for development


continuously.

 MVC applications are more comfortable to modify at any point of time


without effecting the entire project.

21. What is clean & clear URL’s in ASP.Net MVC?


 MVC applications are using URL’s according to the controller.

 All URL’s of MVC are controller based and not file based wherein
ASP.Net URL’s are file based.

 MVC URL’s are called as clean and clear URL’s. Because it contains less
no of characters (query string) in URL. Due to this feature SEO will be
easy.

 Example for ASP.Net WebForm URL’s

/Product.aspx

/Product.aspx?cat=5

/Product.aspx?cat=5&sub=17

 Example for ASP.Net MVC URL’s

/Products

/Products/Shirts

/Products/Shirts/Kids.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 8


ASP.NET MVC Mr.R.N.Reddy

22. How ASP.Net MVC will improve the performance of


web application?
 Comparing with ASP.Net WebForms applications ASP.Net MVC
applications will provide more performance.

 ASP.Net WebForms will process the webpage with lot of activities like
below.

1. Page Events.
2. Server control Objects
3. Load request data
4. Process the values
5. Convert to HTML and so on…

 Due to this behaviour ASP.Net WebForms execution will be time


consuming and adds extra burden on the server.

 ASP.Net MVC doesn’t perform all the above activities because it


doesn’t support server controls .Hence the processing will be faster.

23. How in ASP.Net MVC we can have more


controlling over HTML?
 In ASP.Net MVC, Views (presentation/UI) will be developing with the
help of HTML.

 Due to above reason we can integrate any kind of client side libraries
with MVC views.

 Ex: JQuery, Angular JS, Boot Strap…. are client side libraries.

24. What are the newly added concepts in


ASP.Net MVC?
 In ASP.Net MVC new concepts are added to make web applications
development more comfortable.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 9


ASP.NET MVC Mr.R.N.Reddy

 They are

a) Filters
b) Routing
c) Attribute
d) WEB API
e) Scaffold templates….etc.

25. How ASP.Net MVC is easy to learn and easy to


implement?
 ASP.Net MVC is developed basing on existing Dot Net.

 While developing the ASP.Net MVC application we can reuse the most
of the C#.Net & ASP.Net Web Forms concepts.

26. What are the sub templates we have under ASP.Net


MVC web applications?

 We have below sub templates in ASP.Net MVC web application.


 They are:
1. Empty.
2. Basic.
3. Internet Application.
4. Intranet Application.
5. Mobile Application.
6. Web API.

27. Which template is suitable for beginners?

 Basic template is more suitable for the beginners.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 10


ASP.NET MVC Mr.R.N.Reddy

28. What is the difference between basic and empty


templates in ASP.Net MVC Web application?

 Differences between Empty template & Basic template.

Empty template Basic template

Same as ASP.Net empty web Same as Empty template.


application.
It generates empty folders. It generates 2 more folders
than empty template, for
client side programming.

We need to develop from We need to develop from


scratch scratch with default styles and
scripts.

29. What is the difference between Internet


application and Intranet application?

 Differences between Internet application & Intranet application

Internet Application Intranet Application

Network type is Public Network type is private

Accessibility is throughout the Accessibility is within the


globe organization

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 11


ASP.NET MVC Mr.R.N.Reddy

30. What is the difference between Internet


application and Intranet application in ASP.Net MVC
Web application?

 Differences b/w Internet & Intranet application in ASP.NET MVC

Internet Application Intranet Application

Follows “Form Authentication Follows “Windows


Security”. Authentication Security”.

Same as ASP.Net Web Same as Internet application.


application.

31. Which authentication will be following by


the ASP.Net MVC Internet application?

 ASP.Net MVC Internet application will follow “Form


Authentication Security”.

32. Which authentication will be following by


the ASP.Net MVC Intranet application?

 ASP.Net MVC Intranet application will follow “Windows


Authentication Security”.

33. What we can do by using Web API?

 Web API template is used to create service based applications


in MVC pattern.

34. What we can do by using WCF?

 WCF is used to develop web service applications in traditional


manner.
RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 12
ASP.NET MVC Mr.R.N.Reddy

35. What is the difference between WCF and Web API?

 Differences b/w WCF and Web API in ASP.NET MVC.

WCF Web API

WCF is used to develop web Web API used to develop web


service applications in service application using MVC
traditional manner. design pattern

Follows various protocols. Follows HTTP Protocol.

36. In DOT Net which services are called as


HTTP Services?

 In DOT Net Web API Services are called as HTTP Services.

37. Why Web API services are called as HTTP Services?

 Web API Services follows only HTTP Protocol that’s Web API
services are called as HTTP Services.

38. Which protocol will be used by Web API services?

 Web API Services uses HTTP Protocol.

39. Write the list of folders which will come with


basic MVC application?

 By default Basic ASP.Net MVC application solution explorer window


will come with following important folders.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 13


ASP.NET MVC Mr.R.N.Reddy

 They are:
1.App_Start.
2.Content.
3.Controllers.
4.Models.
5.Scripts.
6.Views.

40. What App_Start folder will contain?

 App_Start folder will contain application start-up setting related files.


 By default App_Start folder will come with four Csharp files.
 They are:
1.BundleConfig.cs.
2.FilterConfig.cs.
3.RouteConfig.cs.
4.WebApiConfig.cs

41. List out the default files in App_Start folder?

 By default App_Start folder will come with four Csharp files.


 They are:
1.BundleConfig.cs.
2.FilterConfig.cs.
3.RouteConfig.cs.
4.WebApiConfig.cs

42. Where will we define default Controller?

 We will define default controller in RouteConfig.cs.

43. What is the importance of RouteConfig.cs file?

 RouteConfig.cs will have details about default controller.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 14


ASP.NET MVC Mr.R.N.Reddy

44. Where we should add application start-up


setting Related files?

 App_Start folder.

45. What Content folder will contain?

 Content folder contains all CSS files.


 We may add images also in this folder if we required.

46. Where we should add CSS files?

Content folder.

47. Where we should add Image files?

 Content folder.

48. What Controller folder can contain?

 Controller folder will contains all controller class files (.cs files).

49. Can we have multiple controllers?

 Yes, we can have multiple controllers but every controller file have
to be a “Csharp class file” ,extension will be .cs file

50. What Model folder can contain?

 Model folder contains Database logic related C# files.


 Here we will implement ADO.Net code or Entity framework code.

51. What is the extension of model files?

 Extension of model files will be .cs files.


RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 15
ASP.NET MVC Mr.R.N.Reddy

52. Which code we will write within the model files?

 Database logic related code.

53. What Scripts folder can contain?

 It contains client side scripting files.

54. What files we will have by default within the scripts


folder?

 By default ASP.Net MVC projects will generate JQuery related files


in scripts folder.

55. Where we should add user defined client


side scripting files?

 We can add user defined client side scripting files in scripts folder.

56. What Views folder will contain?

 Views folder can contain Webpages.

57. How to develop views in ASP.Net MVC?

 In ASP.Net MVC Views are developed with C# code and HTML tags.

58. What is the extension of views files in


ASP.Net MVC?

 The extensions of views files in ASP.Net MVC will be (*.cshtml).

By: HARIBABU VANGA

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 16


ASP.NET MVC Mr.R.N.Reddy

59. What are the responsibilities of controller?

 Controller will perform the following activities


1. Receiving the request.
2. Process the request by executing action method to
communicate with model (or) to communicate with view.
3. Executes the corresponding view.
4. Sending the response.
5. At the time of execution of action method controller will
communicate with model based on the requirement.

60. When controller will communicate the model?

 At the time of execution of action method controller will


communicate with model based on the requirement.

61. What is a controller?

 Controller is important module in MVC which will take care of


execution of every request.
 Controller is responsible for application execution logic.

62. Can we have multiple controllers?

 Yes. But every controller file should be C# class file and


extension will be (.cs).

63. What controller class will contain?

 Controller class will contain corresponding required action methods


to process the requests.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 17


ASP.NET MVC Mr.R.N.Reddy

64. Is controller is user defined or predefined?

 Controller class is a predefined class which is part of a namespace


or Base class library “system.web.mvc”.
 Every user defined controller class should be inherited from
“controller class”.

65. What is the super class for all user defined


controller classes?

 Controller

66. What is the namespace for controller class?

 Controller class is a predefined class which is part of a


namespace or Base class library “System.Web.Mvc”.

67. Write the inheritance hierarchy of all


controller class?

 Diagram of Inheritance hierarchy of controller class.

Object Icontroller

Controller base

Controller

Student Controller

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 18


ASP.NET MVC Mr.R.N.Reddy

68. What is the base class for controller


predefined class?

 Controller class is a predefined class which is part of Base


class library “System.Web.Mvc”.

69. Is controller predefined class and controllerbase


predefined class or what type of class?

 Here Controller class and ControllerBase class are


predefined Abstract class.

70. What is the super class for controller base class?

 Icontroller.

71. What is IController?

 IController is a predefined Interface.

72. What is the highest super class for all


controller classes?
 Icontroller.

73. What is Acton method can contain?

 Action method contains request processing logic.

74. Write the syntax of Action method?

 Public ActionResult Index()


{
Return view ();
}

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 19


ASP.NET MVC Mr.R.N.Reddy

75. Can I write Action method as a static method?

 No

76. What is the Access modifier for Action method?

 Public

77. What is the return type of index method?


 ActionResult.

78. Which method is calling by the index method?

 ViewResult.

79. What is the return type of view method?

 View method return type is ViewResult.

80. Is view method is user (or) predefined?

 Predefined

81. What is ViewResult?

 View result is a predefined class which is part of a base


class library called “System.Web.Mvc”

82. What is derived class of Action result class?

 ViewResult is a derived class of ActionResult class.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 20


ASP.NET MVC Mr.R.N.Reddy

83. What is Action Result?

 Action method return type is ActionResult.


 Here ActionResult is a predefined abstract class which is part of
system.web.mvc.

84. Write the type of Action methods?

 Action methods are 3 types.


1. Action method with ViewResult.
2. Action method with non ViewResult.
3. Non Action method.

85. What is action method with ViewResult?

 Action method that will return view page as output those methods
come under this type.
 These method return statement will be like
below return view()
 These methods required a view page with corresponding
method name
 Example: Index.cshtml.

86. What Action method with ViewResult will return?

 Most of the Action methods will return “ViewResult”.


 These method return statement will be like
below return view()

87. What is Action method with non viewResult?

 Action method with non viewResult that will return data instead of
html formatted output.[webpage].

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 21


ASP.NET MVC Mr.R.N.Reddy

88. What Action method with non viewResult


will return?

 These methods will return single value/object/collection of objects.


 These methods having return statement like below.
i. return Json();
ii. return content();

89. What is non Acton method?

 If we want to define a method that should Access with in the


Controller which is not for end user can be called as non-Action
methods

90. Which Attribute we will use to define non Action


method?

 [“Non Action”].

91. In which programming we will use action


methods with non viewResult?

AJAX.

92. What is an attribute in ASP.Net MVC?

 Attribute in ASP.Net MVC are used to provide special instruction to


execution engine.
 Every Attribute in ASP.Net MVC were developed as a
predefined class.
 All the predefined classes are defined by Microsoft with in a base
class library called “System.Web.Mvc”.

93. How attribute is defined by Microsoft?

 Every Attribute in ASP.Net MVC were defined as a predefined class


by Microsoft.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 22


ASP.NET MVC Mr.R.N.Reddy

94. What is the base class library or namespace


for attribute class?

 All the predefined classes are defined by Microsoft with in a base


class library called “System.Web.Mvc”.

95. Write the list of predefined attribute classes?

 [NonActionAttribute].
 [HTTPGetAttribute].
 [HTTPPostAttribute].

96. Where we will write the attribute?


 We will write particular attribute within” [ ]”.

97. Which attribute we will use to define a non-


action method?

 [NonActionAttribute].

98. Which will executes views in ASP.Net MVC?

 In MVC application execution of views are processed by


special view Engine called “view Engine”.

99. What is view Engine? What is the role of


view engine?

 View Engine is subsystem of MVC Framework.


 View Engine can independently process the views.
 If any changes in view page no need to compile entire project.
 Views are separately processed by “view Engine”.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 23


ASP.NET MVC Mr.R.N.Reddy

100. What are the view engines supported by


ASP.Net MVC?

 Microsoft has developed two view Engines that are integrated with
ASP.Net MVC
1. WebForm (.aspx) View Engine.
2. Razor View Engine

101. In which version ASP.Net MVC WebForm


view engine was introduced?

 Web Form View Engine is introduced in ASP.Net MVC1.0.

102. What are the limitations of WebForm view engine?

Limitations of WebForm View Engine:


 Writing server code (csharp code) in .aspx file is complex.
 It’s not much comfortable for programmers to
perform development modification testing.

103. In which version ASP.Net MVC Razor view engine


was introduced?

 Razor Engine was introduced in ASP.Net MVC 3.0.

104. What are the advantages of razor view engine?

 Less code to implement Server Side Logic.


 Razor Engine is having automatic recognition of c# statements
and HTML tags .Because its advanced view engine.
 Easy to perform unit testing and more comfortable for
development and modifications which contains mixing of
html and C#.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 24


ASP.NET MVC Mr.R.N.Reddy

105. What is the view engine extension of razor


view programming?

 In Razor programming view page extension will be cshtml.

106. How many ways we can integrate C# code


within view in razor programming?

 We can integrate server related items (c# code) in view in


the following ways.
 Inline Statement, SingleLine Statement, Multiple Line Statement.

107. What we can declare by using Inline statements?

 We can declare csharp variables/objects in html tags.

108. Syntax for inline statements?

 String uname=”hari”
<h1>Welcome to @uname<h1>
o/p: Welcome to hari.

109. When we can go for single line statement?

 If we want to write one line of C# code then we can go


for single statement.

110. What can we do by using single line statement?

 If we want to write one line of C# code, then we can use


this option.

111. Write the syntax for single line statement?

 @{ C# Statement}
 Ex:@{ string name=”haribabu”}

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 25


ASP.NET MVC Mr.R.N.Reddy

112. When we can go for multiple line statements?

 If we want to write more than one line of C# code, then we


can use this option.

113. Write the syntax for multiple line statements?

 @{
int x=10;
if(x%2==0)
{
<h1>@x is even<h1>
}
else
{
<h1>@x is odd<h1>
}}

114. How many types of requests we will have


in ASP.Net MVC?

 Get Request
Post Request

115. What is get request?

 Get Request:
We can make request by entering the url or clicking
the hyperlink.
The purpose of get request is to get the webpage from server.

116. What is post request?

 Post Request
We can make post request by clicking the submit
button. Browser will submit the request based on action
method attribute.
 For Ex: <form action=”Home/Index method =”post”</form>

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 26


ASP.NET MVC Mr.R.N.Reddy

117. How browser will submit the request?

 Browser will submit the request based on action


method attribute.
 For Ex: <form action=”Home/Index method =”post”</form>

118. How to read the values with the help of server


code in ASP.Net MVC?

 We can read the values by using request object.


 Request object will return the values in string format.

119. Write the syntax to read the values by using


request object?

 String hari=Request[“textboxname”];

120. What is return type of request object?

 Return type of request object is “String”.

121. What is first request?

 A request which is generated for a web page first time is


called first request.
 A web page will have only one first request.

122. What is post back request?

 Whenever user will interact with webpage with the help of


controls like clicking the button or selecting the radio button
or select checkbox and so on, one request will generate which
is called as PostBack request.

RN Reddy IT School our FB Link: http://www.facebook.com/groups/rnreddytechsupports Page 27


ASP.NET MVC Mr.R.N.Reddy

123. How to identify first request and post back request


in ASP.Net MVC?

 In MVC view page provides a property called IsPost to


recognize request or postback request.

124. Explain about is post property?

 It’s a Boolean property and it contains “true” or “false”.

125. What is the default value of the IS Post?

Default value of is post is “false”.

126. When Is Post property will have true value?

 Whenever its postback request then is post value is “true”.

127. When Is Post property will have false value?

 Whenever its first request then is post value is “false”.

128. How to access is post property?

 Using (this.IsPost).
WCF Interview Questions
1) What we can do by using WCF?

Ans: Using WCF, we can develop a web service.

2) What is web service?

Ans:A unit of code which is providing services to multiple client applications is called as web
service

3) What is service provider?

Ans:A unit of code which is providing service is called as service provider.

4) What is service receiver?

Ans: A unit of code which is providing service is called as service provider.

5) When we will go for Web service?

Ans: Whenever multiple applications required same functionality, we will develop that common
functionality as a web service and which can be consumed by required applications.

6) What are homogeneous applications?

Ans: If service provider and service receiver developed by using same technology which are
called as homogeneous applications.

7) What are heterogeneous applications?

Ans: If the service provider developed by one technology and service receiver developed by
another technology which are called as heterogeneous applications.

8) What is interoperability?

Ans: Whenever service provider and service receiver are in different platform, it means one
technology web service is consumed by another technology developed application. For eg: Dotnet
web service is consumed by Java client application as well as Java web service is consumed by
Dotnet client application.

9) How to develop a web service by using .Net?

Ans: In .Net we have 3 web service technologies,


a) Xml webservices b) WCF c) Web API

10) What are xml webservices?


Ans:Xml web services is a .Net traditional web service technology which was introduced by
Microsoft with .Net 1.0.

11) What is WCF?

Ans:Due to limitations of xml web services, Microsoft has introduced a new web service
technology i.e. WCF with .Net 3.0 version in the year 2006.

12) Write the structure of IServices1.cs file?

Ans:
[ServiceContract]
public interface IService1
{
//here we have to declare WCF service required methods
}

13) Write the structure of Service1.svc.cs file?

Ans:
public class Service1:IService1
{
//Implementing IService1 interface members
}

14) What is ServiceContract?

Ans:It is WCF Interface.

15) What is OperationContract?

Ans:It is WCF Service method.

16) What is DataContract?

Ans:It is WCF Userdefined type.

17) What is DataMember?

Ans:It is a WCF property.


Web API Interview Questions
1) What is API?

Ans:API stands for Application Programming Interface.

2) What is Web API?

Ans:Web API is a new framework to develop service based applications.

3) Why Web API service are called as HTTP Services?

Ans: In Web API communication between service provider and service receiver will be with the
help of HTTP. Hence they are called HTTP Services.

4) What do you mean by device independent and application independent services?

Ans:Web API service can be accessed from all devices like Desktop, Laptop, Tablets, Mobile
devices, etc as well as Web API service can be consumed from various types of applications like
Windows Forms application, Web Application, Mobile Application.

5) Why Microsoft has introduced Web API even though it is having WCF/Web Service?

Ans:Since WCF/ XML web services requires additional protocol called SOAP, Microsoft introduced
Web API as it does not require any special protocols like SOAP, TCP, etc.

6) What is SOAP?
Ans:SOAP stands for Simple Object Access Protocol. SOAP is a xml based protocol.

7) Which protocol will follow the WCF Restful Services?

Ans:HTTP protocol.

8) What is ASP.Net Web API?

Ans:ASP.Net Web API is a new framework for building HTTP based services.

9) How Web API is related to ASP.Net MVC?

Ans:Web API concept is developed based on ASP.Net MVC framework.

10) Advantages of Web API?

Ans:Following are the advantages of Web API:


a) It does not require any special protocols like SOAP, TCP, etc.
b) It doesnot require any configuration details. We can simply access by using url.
c) Multiple HTTP clients can communicate with Web API. eg: Desktop, Mobile devices,
tablets, browsers, etc.

11) What is the super class for Web API controller class?

Ans:ApiController class.

12) What is the base class library for Api controller?

Ans:System.Web.Http.ApiController

13) Write the structure of ValuesController file.

Ans:
public class ValuesController :ApiController
{
public IEnumerable<string>Get()
{
return new string[] {“value1”,”value2”};
}
public string Get(int id)
{
return “value”;
}
public void Post([FromBody] string value)
{ }
public voidPut(int id , [FromBody] string value)
{ }
public voidDelete(int id)
{ }
}

14) What is the configuration file for WebApi?

Ans:webapi.config

15) List out Action Methods within the ValuesController.

Ans:a) Get(),
b) Get(int id),
c) Post([FromBody] string value),
d) Put(int id,[FromBody] string value)
e) Delete(int id)

16) What is the purpose of Get() method without parameters?

Ans: Handles HttpGet request

17) What is the the purpose of Get() method with 1 parameter?

Ans:Handles HttpGet request with query string

18) What is the purpose of Post() method?

Ans:Handles HttpPost request.

19) What is the purpose of Put method?

Ans:Handles HttpPut request.

20) What is the purpose of Delete method?

Ans:Handles HttpDelete request.

21) Write the url to call the first Gyet() method?

Ans:http://localhost:1234/api/values

22) Write the url to call the second Get() method.

Ans:http://localhost:1234/api/values?id=1

23) Write the url to call the Post() method.

Ans:http://localhost:1234/api/values

24) Write the url to call the Put method.


Ans:http://localhost:1234/api/values?id=1

25) Write the url to call the Delete method.

Ans:http://localhost:1234/api/values?id=1

26) Write the differences between WCF and Web API.

Ans:

WCF Web API

Stands for Windows Communication Stands for Web Application Programming


Foundation Interface

Requires additional protocol called SOAP Does not require any special protocols like
which is xml based protocol. SOAP, TCP, etc.

It is complex to configure WCF RESTful Does not require any configuration details.
services. We can simply access by using url.

ASP.Net MVC Interview Questions


Linq Interview questions
1) What is Linq?

Ans:Linq stands for Language Integrated Query, which was introduced by the MicroSoft, with .Net
Framework 3.5. Linq is advanced data access object, ADO.Net is traditional data access object.

2) What we can do by using Linq?

Ans:Using Linq, a .Net application can communicate the databases.

3) What is difference between ADO.Net and Linq?

Ans:Using ADO.Net to communicate the databases within the .Net application, we will write the
SQL commands like select, insert,update,delete,create,etc.
Butusing Linq to communicate the databases within the .Net application, we don’t require to
write Sql commands. These Sql commands we can implement by using any one of the .Net
language like C#.Net or Vb.Net.

4) In which version of .Net, Linq is introduced?

Ans:.Net framework 3.5.

5) Write the syntax for Linq query

Ans:ORToolClassName<variableobjectname> =new ORToolClassName();


var <variablename> =
from <aliasname> in <variableobjectname>.<tablepropertyname>
select <aliasname>;
eg:
LinqToSqlDataContextlinkobj=new LinqToSqlDataContext();
var v1=from empnew in linkobj.Emps select empnew;

6) What is OR tool?

Ans:To communicate the datasourcesby using Linq, Microsoft is providing one predefined tool
called OR Tool (object relational).

7) What will provide by OR tool?

Ans:OR tool will be providing one predefined class that predefining class will having various
predefined methods to implement remaining operations on databases like insert, update, delete
and so on.

8) Using Linq what we can communicate?

Ans:Using Linq, we can communicate the datasources like collections, databases, xml.

9) What is the predefined method we will use for inserting the data into database by using Linq?

Ans: InsertOnSubmit().

10) What is the predefined method we will use to perform Delete,Update operation by using Linq?

Ans:Single()

11) What is the role of SubmitChanges method in Linq?

Ans:It is a predefined member method of DataContext predefined class.This method will confirm
insert, delete or update operations like ‘commit’.

12) Write the structure of RouteConfig file in MVC?

Ans:public class RouteConfig


{
public static void RegisterRoutes(RouteCollection Routes)
{
Routes.Ignore(“{resource}.axd/{*pathInfo}”);
Routes.MapRoute(name:”Default”,Url:”{Controller}/{action}/{id}”
Defaults:new{Controller=”Home”,action=”Index”,id=”urlparameter.optional”}
);
}//method
}//class

13) What is the attribute of RouteConfig.cs which will decide first controller?

Ans:Controller attribute

14) What is the attribute of RouteConfig.cs which will decide first action method to execute at first
request?

Ans:action attribute

15) Can we have multiple action methods within a single view?

Ans:Yes

16) Can we have multiple views?

Ans:Yes

Entity Framework Interview questions

1) What is Entity framework?

Ans:Entity Framework is an advanced .Net data access technology.

2) When we will go for Entity Framework?

Ans:Whenever we want to have more productivity, maintainability and improved performance


using a data access technology, we will go for Entity Framework.

3) In which .Net version, Entity framework was introduced?

Ans:.Net framework 3.5 version after the introduction of Linq.

4) What is the latest Entity Framework released and in which year?

Ans:Entity Framework 6.0 in 2012.

5) What is the difference between ADO.Net and Entity Framework?


Ans:

6) What is the difference between Linq and Entity Framework?

Ans:

7) What is ORM tool?

Ans:ORM stands for Object Relational Mapping. It automatically creates class which are based on
the database tables.

8) What are the advantages of Entity Framework?

Ans:Advantages of Entity Framework:


1) Productivity: Entity framework will reduce the coding part which makes the programmer
task easy thereby improves the performance of the programmer.
2) Maintainability: In entity framework data access code is very less which will make the
maintenance easy.
3) Improved Performance: In entity framework, first request to fetch the details little bit slow
but after that it is very fast to fetch data from database for post back request.

9) What is the method to insert a record in Entity Framework?

Ans:Add() and SaveChanges().

10) What is the method to delete a record in Entity Framework?

Ans:Find() for finding the record and Remove() for deleting.

11) What is the method to update a record in Entity Framework?

Ans:Find() for finding the record and SaveChanges() to update the values.

12) What is the method to find a record in Entity Framework?

Ans:Find().

13) Write the Entity Framework code (query) syntax to fetch the data from single table.

Ans:mydbEntitiesobjdb=new mydbEntities();
var countrylist=objdb.Countries;

14) Write the Entity Framework code(query) to fetch the data from two tables(joins).

Ans:mydbEntitiesobjdb=new mydbEntities();
var loc=from c in objdb.Countriesjoins in
objdb.Statesonc.countryidequalss.countryidselectnewLocationModel
{Cname=c.countryname,Sname=s.statename};

 Here Cname and Sname are properties defined inside the LocationModel class.
 countryid, countryname and statename are column property names of countries and
states table properties respectively which are coming with ORM tool
 LocationModel is the model class name.

15) Write the Entity Framework code(query) to fetch the data from three tables(joins).

Ans:mydbEntitiesobjdb=new mydbEntities();
var loc=from co in objdb.Countriesjoins in objdb.Statesonc.countryidequalss.countryidjoin ci in
objdb.citiesons.stateidequalsci.stateidselect newLocationModel {Cname=co.countryname,
Sname=s.statename, Ciname=ci.cityname};

16) Write the above syntax for 4 tables.

Ans:mydbEntitiesobjdb=new mydbEntities();
var loc=from co in objdb.Countriesjoins in objdb.Statesonc.countryid equals s.countryidjoin ci in
objdb.citiesons.stateidequalsci.stateidjoinm in objdb.mandals on ci.cityidequalsm.cityidselect
newLocationModel {Cname=co.countryname, Sname=s.statename,
Ciname=ci.cityname,Mname=m.mandalname};

17) Write the above syntax for 5 tables.

Ans:mydbEntitiesobjdb=new mydbEntities();
var loc=from co in objdb.Countriesjoins in objdb.Statesonc.countryid equals s.countryidjoin ci in
objdb.citiesons.stateidequalsci.stateidjoinm in objdb.mandals on ci.cityidequalsm.cityidjoinv in
objdb.villages on m.mandalidequalsv.mandalidselect newLocationModel
{Cname=co.countryname, Sname=s.statename,
Ciname=ci.cityname,Mname=m.mandalname,Vname=v.villagename};

Bundling And Filters Interview Questions

1) What is bundling?

Ans:Bundling is a technique introduced in MVC4.5 to improve request load time.

2) When bundling was introduced?

Ans:Bundling was introduced in MVC 4.5

3) Why bundling or what we are achieving with bundling?


Ans:Bundling allows us to load the bunch of static files from the server into one HTTP request.

4) What is minification?
Ans: Minification Technique optimizes script or css file size by removing unnecessary white spaces and
comments and shortening variable names to one character.

5) Explain/What we are achieving with minification.


Ans: Minification removing unnecessary white spaces, comments and also shortening variable names to
reduce the characters which in finally it will reduce the size of JavaScript file.
6) What is the base class library for all bundle classes?
Ans: System.Web.Optimization
7) List out all the bundle types or classes.
Ans: a) Script Bundle
b) Style Bundle
c) Dynamic Folder Bundle
8) What is the role of Script Bundle?
Ans: Script Bundle is responsible for JavaScript minification of single or multiple script files.
9) What is the role of StyleBundle?
Ans: Style Bundle is responsible for css minification of single or multiple style sheet files.
10) What is the role of Dynamic Folder Bundle?
Ans: It Represents a bunle object thet ASP.Net creates from a folder that contains files of same type.
11) What is routing?
Ans: Routing defines execution flow for a particular request
 In ASP.Net every request will contain like below
http://domain/studentinfo.aspx
 Means in ASP.Net requet it is targeting the .aspx file due to that reason these Url’s are called file
bsed Url’s.
 To avoid Mapping each Url with a physical file in ASP.Net MVC introduced a new concept called
routing
 In MVC routing enables US to define Url pattern that mapping to the request handler
 The request handler can be file or class
 In ASP.Net request handler is .aspx file but in MVC request handler is Controller class and Action
Method
 For Example: http://domain/student/Index
 Here Students is Controller and Index is Action Method
12) What is the ASP.Net URL pattern?
Ans: http://domain/studentinfo.aspx
13) What is the MVC url pattern?
Ans: http://domain/student/Index
14) How to overcome file based url?
Ans: with routing
15) What is route?
Ans: Route defines the Url pattern and handler information
 All the Configured routes of an application stored internally in Route Table and will be used by
routing engine to determine appropriate handler class or file for an incoming request.
16) Where to configure a route in mvc?
Ans: Every MVC application must configure atleast one route which is configured by MVC Framework by
default. Tou can register a route with in RouteConfig class which is in RouteConfig.cs under App_Start
folder
17) Write the structure of RouteConfig.cs file

Ans:
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional} );
}
}
18) Which method will initiate the Routes in RouteConfig.cs file?
Ans: MapRoute
19) Write the list of available filters in mvc.
Ans: a. Authentication Filers
b. Authorization Filters
c. Action Filters
d. Result Filters
e. Exception Filters
20) What is the role authentication filters?
Ans: Authentication Filter runs before any other filter or any action method.
 Anthentication confirms that valid user or invalid user
 Action Filters implements the Authentication filter interace that is IAuthenticationFilter
21) What is the interface of authentication filters?
Ans: IAuthenticationFilter
22) What is the role of authorization filters?
Ans: Authorization filters are responsible for checking user access, these implements the
IAuthorizationFilter interface within framework
23) What is the interface of authorization filters?
Ans: IAuthorizationFilter
24) What is the role of Action filters?
Ans: Action Filter can apply on entire controller or single action method. This filter will be called before
and after the action has executed.
 These Action Filters contain logic i.e; executed before and after a controller action executes, you
can use action filter to modify the ViewData that a controller action returns interface of Action
Filter is IActionFilter
25) What is the interface of Action filters?
Ans: IActionFilter
26) What is the role of Result filters?
Ans: The filters contains logic that is executed before and after a View result is executed that means
result filter will execute before view result and after result, interface is IResultFilter
27) What is the interface of Result filters?
Ans: IResultFilter
28) What is the role of Exception filters?
Ans: Exception filters will Exception filter to handle errors raised by either your Controller actions or
controller action results.
 Interface of Exception Filter is IExceptionFilter
29) What is the interface of Exception filters?
Ans: I ExceptionFilter

You might also like