You are on page 1of 54

1.

Choose the form in which Postback occur


A. HTMLForms

B. Webforms

C. Winforms

Ans: Webforms

2. Web.config file is used...

A. Configures the time that the server-side codebehind module is called

B. To store the global information and variable definitions for the application

C. To configure the web server

D. To configure the web browser

Ans: To store the global information and variable definitions for the application

3. Which of the following object is not an ASP component?

A. LinkCounter

B. Counter

C. AdRotator

D. File Access

Ans: LinkCounter

4. The first event triggers in an aspx page is.

A. Page_Init()

B. Page_Load()

C. Page_click()

Ans: Page_Init()

5. Difference between Response.Write() andResponse.Output.Write().

A. Response.Output.Write() allows you to buffer output

B. Response.Output.Write() allows you to write formatted output

C. Response.Output.Write() allows you to flush output

D. Response.Output.Write() allows you to stream output

Ans: Response.Output.Write() allows you to write formatted output

6. Which of the following method must be overridden in a custom control?

A. The Paint() method

B. The Control_Build() method

C. The default constructor

D. The Render() method


Ans: The Render() method

7. How do we create a FileSystemObject?

A. Server.CreateObject("Scripting.FileSystemObject")

B. Create("FileSystemObject")

C. Create Object:"Scripting.FileSystemObject"

D. Server.CreateObject("FileSystemObject")

Ans: Server.CreateObject("Scripting.FileSystemObject")

8. Which of the following tool is used to manage the GAC?

A. RegSvr.exe

B. GacUtil.exe

C. GacSvr32.exe

D. GacMgr.exe

Ans: GacUtil.exe

9. What class does the ASP.NET Web Form class inherit from by default?

A. System.Web.UI.Page

B. System.Web.UI.Form

C. System.Web.GUI.Page

D. System.Web.Form

Ans: System.Web.UI.Page

10. We can manage states in asp.net application using

A. Session Objects

B. Application Objects

C. Viewstate

D. All of the above

Ans: All of the above

11. Attribute must be set on a validator control for the validation to work.

A. ControlToValidate

B. ControlToBind

C. ValidateControl

D. Validate

Ans: ControlToValidate

12. Caching type supported by ASP.Net


A. Output Caching

B. DataCaching

C. a and b

D. none of the above

Ans: a and b

13. What is used to validate complex string patterns like an e-mail address?

A. Extended expressions

B. Basic expressions

C. Regular expressions

D. Irregular expressions

Ans: Regular expressions

14. File extension used for ASP.NET files.

A. .Web

B. .ASP

C. .ASPX

D. None of the above

Ans: .ASP

15. An alternative way of displaying text on web page using

A. asp:label

B. asp:listitem

C. asp:button

Ans: asp:label

16. Why is Global.asax is used?

A. Declare Global variables

B. Implement application and session level events

C. No use

Ans: Implement application and session level events

17. Which of the following is not a member of ADODBCommand object?

A. ExecuteScalar

B. ExecuteStream

C. Open

D. ExecuteReader

Ans: Open
18. Which DLL translate XML to SQL in IIS?

A. SQLISAPI.dll

B. SQLXML.dll

C. LISXML.dll

D. SQLIIS.dll

Ans: SQLISAPI.dll

19. Default Session data is stored in ASP.Net.

A. StateServer

B. Session Object

C. InProcess

D. all of the above

Ans: InProcess

20. Default scripting language in ASP.

A. EcmaScript

B. VBScript

C. PERL

D. JavaScript

Ans: VBScript

21. How do you get information from a form that is submitted using the "post" method?

A. Request.QueryString

B. Request.Form

C. Response.write

D. Response.writeln

Ans: Request.Form

22. Which object can help you maintain data across users?

A. Application object

B. Session object

C. Response object

D. Server object

Ans: Application object

23. Which of the following ASP.NET object encapsulates the state of the client?

A. Session object
B. Application object

C. Response object

D. Server object

Ans: Session object

24. Which of the following object is used along with application object in order to ensure that only one
process accesses a variable at a time?

A. Synchronize

B. Synchronize()

C. ThreadLock

D. Lock()

Ans: Synchronize()

25. Which of the following control is used to validate that two fields are equal?

A. RegularExpressionValidator

B. CompareValidator

C. equals() method

D. RequiredFieldValidator

Ans: CompareValidator

26. Mode of storing ASP.NET session

A. InProc

B. StateServer

C. SQL Server

D. All of the above

Ans: All of the above

27. Which of the following is not the way to maintain state?

A. View state

B. Cookies

C. Hidden fields

D. Request object

Ans: Request object

28. You can have only one Global.asax file per project.

A. Yes

B. No

Ans: Yes
29. ______________ element in the web.config file to run code using the permissions of a specific user

A. < credential> element

B. < authentication> element

C. < authorization> element

D. < identity> element

Ans: < identity> element

30. __________ is a special subfolder within the windows folder that stores the shared .NET component.

A. /bin

B. GAC

C. Root

Ans: GAC

31. Which of the following is the performance attributes of processModel?

A. requestQueue limit

B. maxWorkerThreads

C. maxIdThreads

D. All

Ans: All

32. Which of the following is faster and consume lesser memory?

A. SQLDataReader

B. Data Set

Ans: SQLDataReader

33. Which of the following is the way to monitor the web application?

A. MMC Event viewers

B. Performance logs

C. Alerts Snap-ins

D. ALL

Ans: ALL

34. The ________________ property affects how the .Net Framework handles dates, currencies, sorting
and formatting issues.

A. CurrentUICulture

B. CurrentCulture

Ans: CurrentCulture
35. Where do we include the user lists for windows authentication?

A. < Credential>

B. < authorization>

C. < identity>

D. < authentiation>

Ans: < authorization>

36. Where do we include the user lists for Form authentication?

A. < credential>

B. < authorization>

C. < Identity>

D. < authentication>

Ans: < credential>

37. Which of the following authentication is best suited for a corporate network?

A. Windows

B. Form

C. User

D. All

Ans: Windows

38. What attributes do you use to hide a public .Net class from COM?

A. DLLImport Attributes

B. ComVisible attributes

C. COM Interop

D. All

Ans: ComVisible attributes

39. By default, code written with the Debug class is stripped out of release builds.

A. Yes

B. No

Ans: Yes

40. _________ tests make sure that new code does not break existing code.

A. Regression tests

B. Integration tests

C. Unit tests
D. Load test

Ans: Integration tests

41. The .NET Framework provides a runtime environment called..... ?

A. RMT

B. CLR

C. RCT

D. RC

Ans: CLR

42. In ASP.NET in form page the object which contains the user name is ______ ?

A. Page.User.Identity

B. Page.User.IsInRole

C. Page.User.Name

D. None of the Above

Ans: Page.User.Identity

43. Find the term: The .NET framework which provides automatic memory management using a
technique called ______________ ?

A. Serialization

B. Garbage Collection

C. Assemblies

D. Overriding

Ans: Garbage Collection

44. Which of the following denote ways to manage state in an ASP.Net Application?

A. Session objects

B. Application objects

C. ViewState

D. All the Above

Ans: All the Above

45. What is the base class from which all Web forms inherit?

A. Master Page

B. Page Class

C. Session Class

D. None of the Above

Ans: Page Class


46. WSDL stands for ___________ ?

A. Web Server Description Language

B. Web Server Descriptor Language

C. Web Services Description Language

D. Web Services Descriptor Language

Ans: Web Services Description Language

47. Which of the following must be done in order to connect data from some data resource to Repeater
control?

A. Set the DataSource property

B. Call the DataBind method

C. Both A. and B.

D. None of the Above

Ans: Both A. and B.

48. Which of the following is FALSE?

A. ASP.NET applications run without a Web Server

B. ASP+ and ASP.NET refer to the same thing

C. ASP.NET is a major upgrade over ASP

D. None of the Above

Ans: None of the Above

49. Which of the following transfer execution directly to another page?

A. Server.Transfer

B. Response.Redirect

C. Both A. and B.

D. None of the Above

Ans: Server.Transfer

50. If one has two different web form controls in a application and if one wanted to know whether the
values in the above two different web form control match what control must be used?

A. DataList

B. GridView

C. CompareValidator

D. Listview

Ans: CompareValidator
51. Which of the following is used to send email message from my ASP.NET page?

A. System.Web.Mail.MailMessage

B. System.Web.Mail.SmtpMail

C. Both A. and B.

D. None of the Above

Ans: Both A. and B.

52. In my .NET Framework I have threads. Which of the following denote the possible priority level for
the threads?

A. Normal

B. AboveNormal

C. Highest

D. All the Above

Ans: All the Above

53. In .NET the operation of reading metadata and using its contents is known as ______?

A. Reflection

B. Enumeration

C. Binding

D. Serialization

Ans: Reflection

54. In ASP.NET the < authorization > section contain which of the following elements?

A. < deny >

B. < allow >

C. Both A. and B.

D. None of the Above

Ans: Both A. and B.

55. The type of code found in Code-Behind class is ________ ?

A. Server-side code

B. Client-side code

C. Both A. and B.

D. None of the above

Ans: Server-side code

56. Common type system is built into which of the following:

A. CLR
B. RCT

C. RCW

D. GAC

Ans: CLR

57. The actual work process of ASP.NET is taken care by _____________?

A. inetinfo.exe

B. aspnet_isapi.dll

C. aspnet_wp.exe

D. None of the Above

Ans: aspnet_wp.exe

58. Which of the following allow writing formatted output?

A. Response.Write()

B. Response.Output.Write()

C. Both A. and B.

D. None of the Above

Ans: Response.Output.Write()

59. Which of the following denote the property in every validation control?

A. ControlToValidate property

B. Text property

C. Both A. and B.

D. None of the Above

Ans: Both A. and B.

60. How many classes can a single .NET DLL contain?

A. One

B. Two

C. None

D. Many

Ans: Many

61. Suppose one wants to modify a SOAP message in a SOAP extension then how this can be achieved.
Choose the correct option from below:

A. One must override the method ReceiveMessage

B. One must override the method InitializeMethod

C. Both A. and B.
D. One must override the method ProcessMessage

Ans: One must override the method ReceiveMessage

62. Which of the following can be used to add alternating color scheme in a Repeater control?

A. AlternatingItemTemplate

B. DataSource

C. ColorValidator

D. None of the Above

Ans: AlternatingItemTemplate

63. Suppose a .NET programmer wants to convert an object into a stream of bytes then the process is
called ______________ ?

A. Serialization

B. Threading

C. RCW

D. AppDomain

Ans: Serialization

64. The technique that allow code to make function calls to .NET applications on other processes and on
other machines is

A. .NET Threading

B. .NET Remoting

C. .NET RMT

D. None of the above

Ans: .NET Threading

65. The namespace within the Microsoft .NET framework which provides the functionality to implement
transaction processing is ....................

A. System.EnterpriseServices

B. System.Security

C. System.Diagnostics

D. System.Data

Ans: A

66. Which of the following method is used to obtain details about information types of assembly?

A. GetTypes

B. GetType

C. Both A. and B.

D. None of the Above


Ans: Both A. and B.

67. Which of the following is TRUE about Windows Authentication in ASP.NET?

A. Automatically determines role membership

B. Role membership determined only by user programming

C. ASP.NET does not support Windows Authentication

D. None of the Above

Ans: Automatically determines role membership

68. What tags one need to add within the asp:datagrid tags to bind columns manually?

A. Set AutoGenerateColumns Property to false on the datagrid tag

B. Set AutoGenerateColumns Property to true on the datagrid tag

C. It is not possible to do the operation

D. Set AutomaunalColumns Property to true on the datagrid tag

Ans: Set AutoGenerateColumns Property to false on the datagrid tag

69. Which method do you invoke on the DataAdapter control to load your generated dataset with data?

A. Load ( )

B. Fill( )

C. DataList

D. DataBind

Ans: Fill( )

70. In ASP.NET the sessions can be dumped by using

A. Session.Dump

B. Session.Abandon

C. Session.Exit

D. None of the Above

Ans: Session.Abandon

71. Which of the following languages can be used to write server side scripting in ASP.NET?

A. C-sharp

B. VB

C. C++

D. A and B

Ans: D
72. When an .aspx page is requested from the web server, the out put will be rendered to browser in
following format.

A. HTML

B. XML

C. WML

D. JSP

Ans: A

73. The Asp.net server control, which provides an alternative way of displaying text on web page, is

A. < asp:label >

B. < asp:listitem >

C. < asp:button >

Ans: A

74. The first event to be triggered in an aspx page is.

A. Page_Load()

B. Page_Init()

C. Page_click()

Ans: B

75. Postback occurs in which of the following forms.

A. Winforms

B. HTMLForms

C. Webforms

Ans: C

76. What namespace does the Web page belong in the .NET Framework class hierarchy?

A. System.web.UI.Page

B. System.Windows.Page

C. System.Web.page

Ans: A

77. Which method do you invoke on the Data Adapter control to load your generated dataset?

A. Fill( )

B. ExecuteQuery( )

C. Read( )

Ans: A
78. How do you register a user control?

A. Add Tag prefix, Tag name

B. Add Source, Tag prefix

C. Add Src, Tagprefix, Tagname

Ans: C

79. Which of the following is true?

A. User controls are displayed correctly in the Visual Studio .NET Designer

B. Custom controls are displayed correctly in VS.Net Designer

C. User and Custom controls are displayed correctly in the Visual Studio .NET Designer.

Ans: C

80. To add a custom control to a Web form we have to register with.

A. TagPrefix

B. Name space of the dll that is referenced

C. Assemblyname

D. All of the above

Ans: B

81. Custom Controls are derived from which of the classes

A. System.Web.UI.Webcontrol

B. System.Web.UI.Customcontrol

C. System.Web.UI.Customcontrols.Webcontrol

Ans: D

82. How ASP.Net Different from classic ASP?

A. Scripting is separated from the HTML, Code is interpreted seperately

B. Scripting is separated from the HTML, Code is compiled as a DLL, the DLLs can be executed on
server

C. Code is separated from the HTML and interpreted Code is interpreted separately

Ans: C

83. What's the difference between Response.Write() andResponse.Output.Write()?

A. Response.Output.Write() allows you to flush output

B. Response.Output.Write() allows you to buffer output

C. Response.Output.Write() allows you to write formatted output

D. Response.Output.Write() allows you to stream output

Ans: B
84. Why is Global.asax is used?

A. Implement application and session level events

B. Declare Global variables

C. No use

Ans: C

85. There can be more than 1 machine.config file in a system

A. True

B. False

Ans: A

86. What is the extension of a web user control file?

A. .Asmx

B. .Ascx

C. .Aspx

Ans: A

87. Which of the following is true?

A. IsPostBack is a method of System.UI.Web.Page class

B. IsPostBack is a method of System.Web.UI.Page class

C. IsPostBack is a readonly property of System.Web.UI.Page class

Ans: B

88. The number of forms that can be added to a aspx page is.

A. 1

B. 2

C. 3

D. More than 3

Ans: C

89. How do you manage states in asp.net application

A. Session Objects

B. Application Objects

C. Viewstate

D. All of the above

Ans: A
90. Which property of the session object is used to set the local identifier?

A. SessionId

B. LCID

C. Item

D. Key

Ans: D

91. Select the caching type supported by ASP.Net

A. Output Caching

B. DataCaching

C. a and b

D. none of the above

Ans: B

92. Where is the default Session data is stored in ASP.Net?

A. InProcess

B. StateServer

C. Session Object

D. al of the above

Ans: C

93. Select the type Processing model that asp.net simulate

A. Event-driven

B. Static

C. Linear

D. Topdown

Ans: A

94. Does the EnableViewState allows the page to save the users input on a form?

A. Yes

B. No

Ans: A

95. Which DLL translate XML to SQL in IIS?

A. SQLISAPI.dll

B. SQLXML.dll

C. LISXML.dll

D. SQLIIS.dll
Ans: A

96. What is the maximum number of cookies that can be allowed to a web site?

A. 1

B. 10

C. 20

D. More than 30

Ans: A

97. Select the control which does not have any visible interface.

A. Datalist

B. DropdownList

C. Repeater

D. Datagrid

Ans: C

98. How do you explicitly kill a user session?

A. Session.Close( )

B. Session.Discard( )

C. Session.Abandon

D. Session.End

E. Session.Exit

Ans: C

99. Which of the following is not a member of ADODBCommand object?

A. ExecuteReader

B. ExecuteScalar

C. ExecuteStream

D. Open

E. CommandText

Ans: C

MVC ASP.Net Multiple choice Questions and Answers for 3+ Years experienced
1. Which is the best approach to assign a session in MVC?A)
System.Web.HttpContext.Current.Session["LoginID"] =7;
B) Current.Session["LoginID"] =7;
C) Session["LoginID"] =7;
D) None
Ans: B

2. RedirectToActionPermanent() Method for which Status code represents?


A) 304
B) 302
C) 301
D) 300
E) None
Ans: C

3. RedirectToAction() Method for which Status code represents?


A) 304
B) 302
C) 301
D) 300
E) None
Ans: B

4. What is ActionResult() ?
A) It is an abstract Class
B) It is a Concrete Class
C) Both A and B
D) None
Ans: A

5. What is ViewResult() ?
A) It is an abstract Class
B) It is a Concrete Class
C) Both A and B
D) None

Ans: B

6. return View() works like in ASP.Net MVC C# as


A) Server.Transfer()
B) Response.Redirect()
C) Both A and B
D) None
Ans: A

7. RedirectToAction() works like in ASP.Net MVC C# as


A) Server.Transfer()
B) Response.Redirect()
C) Both A and B
D) None
Ans: B
8. In which format data can be return from XML into table ?
A) DataSet
B) Datatable
C) A and B
D) None
Ans: A

9. Can we use view state in MVC ?


A) Yes
B) No
C) Both A & B
D) None
Ans: B

10. What Request Processing technique follows ASP.Net ?


A) Top-Down
B) Down-Up
C) Pipeline
D) Water fall
Ans: C

11. What is DRY principle in ASP.Net ?


A) Don't repeat yourself.
B) Don't revise yourself.
C) both a and b
D) None
Ans: A

12. What is default authentication in Internet Information Services (IIS)?


A) Standard User
B) Administrator
C) Anonymous
D) None
Ans: C

13. What is the extension of MVC view when using C#?


A) cshtml
B) vbhtml
C) None
D) Both A & B
Ans: A

14. What is the extension of MVC view when using vb.net?


A) cshtml
B) vbhtml
C) None
D) Both A & B
Ans: B
15. How can you comment using Razor Syntax?
A) *@ Comment me *@
B) @* Comment me *@
C) @* Comment me @*
D) *@ Comment me @*
E) None
Ans: B

16. Which Namespace is used for Razor View Engine ?


A) System.Web.Razor
B) System.Web.Mvc.WebFormViewEngine
C) Both A & B
D) None
Ans: A

17. Which Namespace is used for ASPX View Engine ?


A) System.Web.Razor
B) System.Web.Mvc.WebFormViewEngine
C) Both A & B
D) None

Ans: B

18. The Razor View Engine uses to render server side content.
A) @
B) <%= %>
C) Both A & B
D) None
Ans: A

19. The ASPX View Engine uses to render server side content.
A) @
B) <%= %>
C) Both A & B
D) None
Ans: B

20. Which is more faster between ASPX View Engine and Razor View Engine.
A) ASPX View Engine
B) Razor View Engine
C) Both A & B
D) None
Ans: A

21. Does Razor Engine supports for TDD ?


A) Yes
B) No
C) None
Ans: A

22. Does ASPX View Engine supports for TDD ?


A) Yes
B) No
C) None

Ans: B

22. How to Print value from Controller to View in MVC ?


A) ViewBag.ECMDetail = "my message"; and in view @ViewBag.ECMDetail
B) ViewBag.ECMDetail = "my message"; and in view ViewBag.ECMDetail
B) ViewBag.ECMDetail = "my message"; and in view ViewBag.Title
D) None
Ans: A

23. If you have already implemented different filters then what will be order of these filters?
1) Authorization filters
2) Action filters
3) Response filters
4) Exception filters
24. Can you specify different types of filters in ASP.Net MVC application?
1) Authorization filters (IAuthorizationFilter)
2) Action filters (IActionFilter)
3) Result filters (IResultFilter)
4) Exception filters (IExceptionFilter)

25. What are the advantages of using ASP.NET routing?


Answer: Clean URLs is originally brought from Ruby on Rails.
http://www.technologycrowds.com?abc=10 , now clean URL in MVC ASP.Net will be work
like http://www.technologycrowds.com/abc/10
26. What is the significance of ASP.NET routing?
Answer: Default Route Name:
"{controller}/{action}/{id}", // URL with parameters
By default routing is defined under Global.asax file. MVC ASP.Net uses routing to map
between incoming browser request to controller action methods.
27. Can be it possible to share single view across multiple controllers in MVC?
Answer: We can put the view under shared folder, it will automatically view the across the
multiple controllers.
28. Are MVC and Web API merged into one in MVC 6?
A) Yes
B) No
C) Both A & B
D) None
Ans: A

29. Does MVC 6 introduced new JSON project based structure?


A) Yes
B) No
C) Both A & B
D) None
Ans: A

30. Does MVC 6 allow only save change, hitting the save but then refreshing the browser to
reflect changes?
A) Yes
B) No
C) Both A & B
D) None
Ans: A

31. Does vNext is now Open Sourced via the .NET Foundation and open to public
contributions.
A) Yes
B) No
C) Both A & B
D) None
Ans: A

32. Can vNext runs on both Mac and Linux today (Mono Version)?
A) Yes
B) No
C) Both A & B
D) None
Ans: A

33. What is the difference between MVC (Model View Controller) and MVP (Model View
Presenter)?
Answer: MVC controller handles all the requests, MVP handles as the handler and also
handles the all requests as well.

34. How does work Viewstart in MVC (ASP.Net)?


A) Viestart is used to layout of the application.
B) Viewstart is used like Masterpage in traditional forms (ASP.Net pages).
C) Viewstart render first in the views.
D) A, B and C.E) None
Viewstart Code Snippet
@{ Layout = "~/Views/Shared/_Layout.cshtml";}Ans: D
35. Viewstart comes under which folder name ?
A) ViewsB) Account
C) Shared
D) Home
Ans: A
36. Does Viewstart override all Views layout/template under "Views" folder in MVC ?
A) YesB) No
C) Both A & B
D) None
Ans: A
37. What is the name of default Viewstart Page in ASP.Net MVC ?
A) _ViewStart.cshtmlB) _Layout.cshtml
C) _Login.cshtml
D) None
Ans: A
38. Can we use third party View Engine using ASP.Net MVC Engine ?
Yes, below are the top five alternative ASP.Net MVC View Engines.
1. Spark (Castle MonoRail framework projects), Open Sourced, it is popular as
MVCContrib library.
1. NHaml works like inline page templating.
1. NDjango uses F# Language.
1. Hasic uses VB.Net, XML.
1. Bellevue for ASP.NEt view, It respects HTML class first.
39. What is scaffolding using ASP.Net MVC Engine?
Answer: Scaffolding helps us to write CRUD operations blend using Entity Framework, It
helps developer to write down simply even yet complex business logic.
40. What is life cycle in ASP.Net MVC Engine?
Step 1: Fill Route (Global.asax file will hit first).
Step 2: Fetch Route: It will gether information about controller and action to invoke.
Step 3: Request context
Step 4: Controller instance: it calls Controller class and method.
Step 5: Executing Action: It determines which action to be executed
Step 6: Result (View): Now Action method executed and returns back response to view in
differentiating forms like Json, View Result, File Result etc.

41. Which is the way to render Partial View using ASP.Net MVC Razor Engine?
A) @Html.Partial("_PartialHeader")B) @Html.PartialView("_PartialHeader")
C) @Html.PartialHtml("_PartialHeader")
D) B and C
E) None
Ans: A
42. Which Namespace is used to "Display" in Data Annotation using MVC ?
A) System.ComponentModelB) System.ComponentModel.DataAnnotations
C) Both A and B
D) None
Ans: A
43. Which Namespaces are required to Data Annotation using MVC ?
A) System.ComponentModel
B) System.ComponentModel.DataAnnotations
C) Both A and BD) None

Ans: C
44. Are both TempData/ViewData require typecasting in MVC?
A) Both (TempData/ViewData) requires type casting to avoid null exception.B) No,
these (TempData/ViewData) does not require type casting.
C) Both A) & B)
D) None
Ans: A
45. Is ViewBag slower than ViewData in MVC?
A) YesB) No
C) Both A) & B)
D) None
Ans: A
46. Is ViewData faster than ViewBag in MVC?
A) YesB) No
C) Both A) & B)
D) None
Ans: A
47. Are both TempData/ViewData property of Controller base class in MVC?
A) YesB) No
C) Both A) & B)
D) None
Ans: A
48. Does TempData used to pass data from one page to another page in MVC?
A) YesB) No
C) Both A) & B)
D) None
Ans: A
49. Can ASP.Net Web API specialize to XML or JSON ?
A) YesB) No
C) None
Ans: A
50. Does Web API (ASP.Net) supports to non SOAP based like XML or JSON ?
A) YesB) No
C) None
Ans: A
51. Does Web API (ASP.Net) supports to both version mobile apps and others ?
A) YesB) No
C) Both A & B
D) None
Ans: A
52. Can ASP.Net Web API, it works HTTP standard verbs like POST, GET, PUT, DELETE
(CRUD Operations) ?
A) YesB) No
C) Both A & B
D) None
Ans: A
53. Can ASP.Net Web API ability to both self hosting (outside of IIS) and IIS ?
A) YesB) No
C) None
Ans: A
54. Can ASP.Net Web API has ability to transport non HTTP protocols like TCP, UDP,
Named Pipes etc ?
A) Yes
B) NoC) None
Ans: B
55. What is AuthConfig.cs in ASP.Net MVC ?
A) AuthConfig.cs is used to configure route settings
B) AuthConfig.cs is used to configure security settings including sites oAuth Login.C)
None
D) All
Ans: B
56. What is BundleConfig.cs in ASP.Net MVC ?
A) BundleConfig.cs in MVC is used to register filters for different purposes.
B) BundleConfig.cs in MVC is used to register bundles used by the bundling and
minification, serveral bundles are added by default like jQuery, jQueryUI, jQuery
validation, Modernizr, default CSS references.C) All
D) None
Ans: B
57. What is FilterConfig.cs in ASP.Net MVC ?
A) FilterConfig.cs is used to register global MVC filters, HandleErrorAttribute is
registered by default filter. We can also register other filters.B) FilterConfig.cs is used to
register global MVC bundles.
C) None
D) All
Ans: A
58. What is RouteConfig.cs in ASP.Net MVC?
A) RouteConfig.cs is used to register MVC config statements, route config.B)
RouteConfig.css is used to register global MVC bundles.
C) None
D) All
Ans: A
59. What is the difference between HtmlTextbox and HtmlTextboxFor using ASP.Net MVC
Razor Engine?
A) @Html.TextBox is not strongly typed, @Html.TextBoxFor is strongly typed that is
why should be use @Html.TextBoxFor in MVC Razor Engine.B) @Html.TextBox is
strongly typed, @Html.TextBoxFor is not strongly typed that is why should be use
@Html.TextBox in MVC Razor Engine.
C) None
D) Both A and B
Syntax
@Html.Partial("_viewname"); Ans: A
60. What is the benefits of Html.RenderPartial using ASP.Net MVC Razor Engine?
A) @Html.RenderPartial Returns response, moreover requires to create action.B)
@Html.RenderPartial Returns nothing (void), it is faster than @Html.Partial, moreover
requires not to create action.C) NoneD) Both A and BSyntax
@Html.Partial("_viewname");@Html.RenderPartial("_viewname");Ans: B

61. What is the benefits of Html.Partial using ASP.Net MVC Razor Engine?
A) @Html.RenderPartial Returns response, moreover requires to create action.B)
@Html.RenderPartial Returns string value, it is slower than @Html.RenderPartial, moreover
requires not to create action.
C) NoneD) Both A and BSyntax@Html.Partial("_viewname");Ans: B

62. How to check Request coming from which controller using MVC ASP.Net?
A) var _controller =
HttpContext.Current.Request.RequestContext.Values["Controller"].ToString();
B) var _controller =
HttpContext.Current.Request.RequestContext.RouteData.Values["Controller"].ToString();
C) var _controller = RouteData.Values["Controller"].ToString();
D) None
Ans: B

63. For which ModelState.IsValid Validate ?


A) It checks for Entityframework Model state.
B) It checks for valid Model State using DataAnnotations.
C) It checks for SQL database state.
D) None

Ans: B

64. Which Name space is used to create chart using ASP.Net MVC?
A) using System.Web.MVC;
B) using System.Web.Helpers;
c) using System.Web.Chart;
D) All
Ans: B

65. How can we provide Height and Width to MVC Charts ?


A) new Chart(width - 600, height - 400)
B) new Chart(width = 600, height = 400)
C) new Chart(width: 600, height: 400)
D) All

Ans: C

66. How can we set theme to MVC Charts?


A) new Chart(width: 600, height: 400, theme: ChartTheme.Vanilla3D)
B) new Chart(width: 600, height: 400, theme: ChartTheme = Vanilla3D)
C) new Chart(width: 600, height: 400, theme: Vanilla3D)
D) None
Ans: A

67. How can we give Title to MVC Charts?


A) var chart = AddTitle("My First Chart")
B) .AddTitle("My First Chart")
C) .AddTitle('My First Chart')
D) All
Ans: B

68. How can we add Series to MVC Charts?


A) .AddSeries(chartType: "Bar", xValue: xValue, yValues: yValue)
B) .AddSeries(chartType: "Bar", xValue = xValue, yValues = yValue)
C) .AddSeries(chartType: "Bar", xValue: xValue, yValues: yValue)
D) None
Ans: A

69. How can we add Chart Type to MVC Charts?


A) .NewSeries(chartType: "Bar")
B) .Series(chartType: "Bar")
C) .AddSeries(chartType: "Bar")
D) All

Ans: C

70. How can we write Chart output to MVC View?


A) .Write(bmp);
B) Write("bmp");
C) .Write("bmp");
D) All
Ans: C
71. How can we Show Chart output to MVC View?
Ans: C

72. Which name space using can send email in ASP.Net MVC?
A) using System.Net.Mail;
B) using System.Net;
C) using System.Mail;
D) None
MailMessage mail = new MailMessage();
Ans: A

73. If Razor View Engine need to add JQuery function and contain @ special character then
how we can write it in Razor View?
A) Replace @ to @@@ (tripple)
B) Replace @ to @@ (double)
C) None
D) Both (A & B)
Ans: B

74. How to set Default Value to Hidden Input Box using ASP.Net MVC?
A) @Html.HiddenFor(m => m.Name, "Jack")
B) @Html.HiddenFor(m => m.Name, new { Value = "Jack"})
C) @Html.Hidden(m => m.Name, new { Value = "Jack"})
D) None
Ans: B

75. How to check all errors of Model using ASP.Net MVC?


A) var errors = Model.Values.SelectMany(v => v.Errors);
B) var errors = ModelState.SelectMany(v => v.Errors);
C) var errors = ModelState.Values.SelectMany(v => v.Errors);
D) None
Ans: C

76. AuthConfig.cs file is under in which App folder ?


A) App_Data
B) App_Start
C) Content
D) Filters

Ans: B

77. BundleConfig.cs file is under in which App folder ?


A) App_Data
B) App_Start
C) Content
D) Filters
Ans: B

78. FilterConfig.cs file is under in which App folder ?


A) App_Data
B) App_Start
C) Content
D) Filters
Ans: B

79. RouteConfig.cs file is under in which App folder ?


A) App_Data
B) App_Start
C) Content
D) Filters
Ans: B

80. WebApiConfig.cs file is under in which App folder ?


A) App_Data
B) App_Start
C) Content
D) Filters
Ans: B

81. Can you list the main types of result using ASP.Net MVC?
There are total 10 main types of result, ActionResult is main type and others are sub types
of results as listed below:
 System.Web.Mvc.ActionResult
 System.Web.Mvc.ContentResult
 System.Web.Mvc.EmptyResult
 System.Web.Mvc.FileResult
 System.Web.Mvc.HttpStatusCodeResult
 System.Web.Mvc.JavaScriptResult
 System.Web.Mvc.JsonResult
 System.Web.Mvc.RedirectResult
 System.Web.Mvc.RedirectToRouteResult
 System.Web.Mvc.ViewResultBase
82. Which filter will be execute at first using ASP.Net MVC?
A) Action filters
B) Authorization filters
C) Response filters
D) Exception filters
Ans: B

83. Which filter will be execute at last using ASP.Net MVC?


A) Action filters
B) Authorization filters
C) Exception filters
D) Response filters
Ans: C

65 TOP ADO.Net Multiple choice Questions with Answers


pdf
1. What is the default value for the Method attribute in a ASP.NET server-side
Form control
A. GET
B. POST
C. SOAP
D. SMTP
Ans: B

2. Which property allows ASP.NET controls to maintain their values when a


page is posted to itself.
A. EnableViewState
B. MaintainValue
C. SaveValue
D. AutoPostBack
Ans: A

3. In a ASP.NET page, which is the best way to find if the contents of a TextBox
has changed after the form containing the TextBox has been posted back to the
server
A. By comparing the old value with the new value
B. By checking the NewValue property of the TextBox control
C. By handling the TextBox control’s TextChanged event
D. By checking the HasChanged property of the TextBox
Ans: C

4. Which statement among the ones below is correct


A. The Params and Forms collection of the HTTPRequest class are exactly
same and theForms collection has been provided only for backward
compatibility
B. The HTTPRequest class does include the Params collection
C. The HTTPRequest class does include the Forms collection
D. The difference between the Params and Forms collection of the
HTTPRequest class is that the Params collection also represents QueryStrings,
ServerVariables, andCookies
Ans: D

5. Which statement among the ones below is correct


a. If you use the server-side version of the tag, you cannot post the form to a
different page.
b. You can modify the Action attribute of the server-side version of the tag to
post the form to a different page
c. You have to set the Method and Action attributes of the server-side version
of the tag to post the form to a different page
d. You can use the SetAction(. method of the server-side version of the tag to
post the form to a different page
Ans: A
6. If a form is posted to a different page, the you can retrieve the values of the
form elements by
a. Using the properties of the ASP.Net controls
b. Using the GetElementByID(. method
c. Using Request.Params
d. The values cannot be retrieved
Ans: C

7. You are performing Form validations with Validation controls. You need to
group all the errors at the top of the page and also show error messages
besides each element. The messages besides each element need to be detailed
and hence different from the messages at top of the page
A. You can use the ValidationSummary Control to summarize the messages set
in theErrorMessage property of the Validation controls. The messages set in
the Text property of the Validation controls can be displayed besides each
element.
B. The error messages set in the SummaryText property of each Validation
control havingisSummary=true will be automatically grouped at the top of the
page and the messages set in the Text property can be displayed besides each
element.
C. The error messages in the Validation control can only be displayed in a
popup
D. The Validation controls cannot be used in the given scenario
Ans: A

8. How do view states work


A. Using Cookies
B. Using a hidden form field
C. Using Session variables
D. Using Application variables
Ans: B

9. You need to dynamically add a TextBox control to a page and display it at


specific location
A. Place a Label control at the required location in the page and add the control
by manipulating the Text property of the Label control
B. Place a PlaceHolder control at the required location in the page. Use the Add
method of theControls collection of the PlaceHolder control to dynamically add
the required control
C. Build the HTML for the entire page in a String and insert the HTML code for
required control in required place
D. You cannot add a control to a page dynamically
Ans: B

10. You require to create an ASP.NET page with the functionality to allow a user
to upload a file to the server
A. You need to use the System.Web.Upload namespace
B. You need to use a COM component to save the file on the server
C. You need to use the SaveAs method of the HttpPostedFile class
D. The ASP.Net application automatically loops through all the and saves the
uploaded files to a virtual folder called “uploads”
Ans: C

11. You need to programmatically add a user control without using the Register
directive in your code
A. Use AddUserControl
B. Use cannot programmatically add a user control
C. Use UserControl.Add
D. Use LoadControl
Ans: D

12. You need to develop a business component myComp.dll in .Net and use it
in your ASP.NET page
a. You require to register the component using regsvr32.exe
b. You require to register the component using TlbExp.exe
c. You require to copy the component to the /bin directory in your applications
root directory
d. You require to copy the component to the /bin directory in your applications
root directory and register the component using regsvr32.exe
Ans: C

13. Is it possible for multiple aspx pages to use the same code-behind file, if
required
A. Yes
B. No
Ans: A

14. How is a ASP.NET presentation page associated with its code-behind


A. The presentation page includes the code-behind file using #include
B. The presentation page includes the code-behind file using
C. The presentation page inherits from the code-behind
D. The ASP.NET presentation page and the code-behind page have the same
name and hence are automatically associated with each other
Ans: C

15. Which namespace would you use if you need to create an ASP.NET
application with Microsoft SQL Server 2000 as the database.
A. System.Data.SQLServer
B. System.Data.SQLClient
C. System.Data.OleDb
D. System.Data.Microsoft
Ans: B

16. Which namespace would you use if you need to create an ASP.NET
application with Oracle as the database.
A. System.Data.SQLServer
B. System.Data.SQLClient
C. System.Data.OleDb
D. System.Data.NonMS
Ans: C

17. Which statement among the following is correct while opening a connection
using theSQLConnection class
A. You cannot specify a connection string
B. You need to specify a Provider parameter for the connection string
C. You need to use a System DSN
D. You cannot use a DSN
Ans: C

18. What method of the Command object would you use if you need to retrieve
a single value (for example an aggregate value. from a database
A. ExecuteScalar(.
B. ExecuteReader(.
C. ExecuteSingle(.
D. ExecuteNonQuery(.
Ans: A

19. Which are the two things you need to take care of in your ASP.Net
application to take advantage of connection pooling (select two.
A. You need to set the Pooling property of the Connection object to True
B. You need to use the same exact connection string whenever you open a
database connection
C. You need to call the ReleaseToPool(. method after the connection is closed
D. You need to explicitly close the connection with the Close(. method
Ans: B,D

20. You have created a ASP.Net page Transaction by using


A. If a transaction already exists, the page will execute within the context of the
transaction. However it will not create a new transaction
B. If a transaction already exists, the page will execute within the context of the
transaction. If a transaction does not exist, it will create a new one
C. Creates a new transaction for each request
D. You cannot created a ASP.Net page Transaction by using
Ans: B

21. You need to retrieve only schema information about the columns contained
in a database table without retrieving data. Which of the following is the best
way to retrieve it
A. Use the GetSchemaTable(. method of the DataReader in conjunction
withCommandBehaviour.SchemaOnly
B. Use the SchemaOnly property of the Command class
C. Use the GetSchemaOnly(. method of the DataReader
D. You cannot retrieve only schema information without retrieving data
Ans: A

23.What will be the values assigned to the two Label controls lblMessage1 &
lblMessage2 respectively
A. 2 & 3
B. 3 & 3
C. 3 & 4
D. 4 & 4
Ans: C

23. You need to customize the display format of the DataList control
A. Set the DisplayFormat property of the DataList control to Custom
B. Set the CustomFormat property of the DataList control to True
C. ItemTemplate will allow you to format the appearance of each DataList item
D. The display format of the DataList control is predefined and cannot be
customized
Ans: C

24. You have a DataList control containing a LinkButton. What would you do to
raise theDeleteCommand event in the DataList by clicking on the LinkButton.
A. Set CommandName=”delete” in the LinkButton
B. Set the OnDelete property of the DataList to the ID of the LinkButton
C. A DataList control cannot raise an event in response to events raised by its
child controls
D. A DataList control cannot contain child controls
Ans: A

25. The Products table has a column named ProductName and a primary key
column namedProductID. When a user selects an item in the DataList, you want
to retrieve the value of theProductID column associated with it.
A. In the DataList control set PrimaryKeyField=”ProductID”
B. In the DataList control set DataKeyField=”ProductID”
C. In the DataList control set KeyField=”ProductID”
D. In the DataList control set id=”ProductID”
Ans: B
26. You need to enable paging for a DataGrid control
A. You can use a DataReader
B. You can use a DataTable
C. You can use either the DataReader or DataTable
D. A DataGrid does not support paging
Ans: B

27. Can you use a DataView to filter rows in a DataTable


A. Yes, by setting the Filter property of the DataView
B. Yes, by setting the RowFilter property of the DataView
C. Yes, by using the SetFilter(. method of the DataView
D. No, a DataView cannot be used to filter rows in a DataTable
Ans: B

28. Which statement is an accurate description of the code below (dtsDataset is


a DataSet.
Cache(“myCachedDataSet”. = dstDataset
a. Adds a DataSet to the application’s cache in the server’s memory,
automatically preserving it between page requests.
b. Adds a DataSet to the cache in the client’s memory, automatically preserving
it between page requests.
c. The Cache object cannot be used to cache a DataSet, it can only cache a
DataTable
d. The code block is syntactically incorrect and should actually be
Set Cache(“myCachedDataSet”. = dstDataset
Ans: A

29. How can you load an XML file directly into a DataSet
A. By setting the XML property of the DataSet class
B. By using the GetXML(. method of the DataSet class
C. By using the ReadXml(. method of the DataSet class
D. You cannot load an XML file directly into a DataSet
Ans: C

30. Your site has been restructured and the paths of few pages have changed.
Which method would you use to redirect users requesting for a pages using
the old URL
A. Create an ISAPI filter to do the above task
B. Create an entry in the section of the Web.Config file
C. Use the Application.Config file
D. Handle the Application_BeginRequest event and use the RewritePath(.
method
Ans: D
31. Which statement about the Web.Config file is the most accurate
A. The Web.Config file can be only placed in the root of a Web Site to override
settings in theMachine.Config file for all applications in a particular Web Site
B. The Web.Config file can only be placed in the root of a particular virtual
directory
C. The Web.Config file can be placed in the root of the Web Site and the root of
a virtual directory. The settings from the file in the virtual directory overrides
the settings from the file in the Web Site
D. The Web.Config file can be placed in the root of the Web Site and the root of
a virtual directory and in any subdirectory of an application. The settings from
a file at a particular level override the settings from the ones above it.
Ans: D

32. The settings in the Web.Config file are case-sensitive


A. True
B. False
Ans:
33. The settings in the Web.Config file can be configured to apply to
A. An application
B. An application or a particular directory
C. An application or a particular directory or even an individual file
D. The Web.Config file always applies to all pages in the current directory and
its subdirectories
Ans: C

34. Is there a way to prevent configuration settings in a Web.Config file from


being overridden by aWeb.Config file located below it
A. Yes, you can use the allowOverride attribute in the tag to prevent
configuration settings in a Web.Config file from being overridden by a
Web.Config file located below it
B. Yes, you can use the tag to prevent configuration settings in aWeb.Config
file from being overridden by a Web.Config file located below it
C. If a Web.Config file exist at a particular level then all settings in the
Web.Config file located above it are always ignored
D. You cannot have more than one Web.Config file in an ASP.NET application
Ans: A

35. If you have an ASP.NET application with cookieless sessions enabled,


which statement among the
A. You cannot use relative URL’s with cookieless sessions
B. You cannot use absolute URL’s with cookieless sessions
C. Cookieless sessions have no relation with URL’s
D. You cannot have cookieless sessions with an ASP.NET application
Ans: B

ADO.Net Objective type Questions and Answers ::


36. You are part of a team that is using Visual Studio .NET to develop a Web
application. You have placed a number of configuration settings for the
application in the server’s Machine.config file. You learn in a meeting that one
of your co-workers has created a Web.config file to store these settings,
though in comparing notes you realize that you and your co-worker have used
different settings.
Which of the following describes what will happen when you execute the
application
a. The application will run correctly and will use the settings in the Web.config
file, ignoring theMachine.config settings
b. The application will run correctly and will use the settings in the
Machine.config file, ignoring the Web.config settings
c. The application will not run correctly until you either remove the Web.config
file or delete the settings from the Machine.config file
d. The application will run correctly, using only the settings that are identical in
the Web.configand Machine.config files
e. The application will not run correctly until you modify either the Web.config
file or theMachine.config file so that the application settings are identical
Ans: A

37. You are preparing to deploy an ASP.NET Web application. You are currently
creating the deployment project. You have started the Web setup project, which
is namedAccountManagerDeploy, and added the application output to the
project, and now you need to set the directory on the Web server to which the
application will be installed. Which of the following procedures should you use
to do so (Choose two. Each correct answer presents part of the solution..
A. Set the VirtualDirectory property in the Properties window.
B. Select the Web Application Folder in the File System Editor.
C. Select the AccountManagerDeploy project in the Solution Explorer.
D. Set the Folder property in the Properties window.
E. Select the Primary output from AccountManagerDeploy icon in the Solution
Explorer.
Ans: A, B

38. You are part of a team that is using Visual Studio .NET to develop a Web
application. You are looking through the files in the application, and you see
the following files:
createmembership.aspx
createmembership.aspx.vb
Which two of the following statements most accurately describe these two files
(Select two..
A. The createmembership.aspx.vb file is a Web form, which displays a user
interface to the user
B. The createmembership.aspx file is a code file, which contains code that
interacts with the user interface in the Web form
C. The createmembership.aspx file is an uncompiled file that will become
createmembership.aspx.vb when it is compiled
D. The createmembership.aspx.vb file is a code file, which contains code that
interacts with the user interface in the Web form
E. The createmembership.aspx file is a Web form, which displays a user
interface to the user
F. The createmembership.aspx.vb file is the compiled version of
createmembership.aspx
Ans: D, E

39. You are using Visual Studio .NET to develop a Web application. You are
beginning to debug your application, and you would like to store debug
messages in the Windows event log as you proceed with testing. Which of the
following will allow you to do so
A. TextWriterTraceListener
B. DefaultTraceListener
C. EventLogTraceListener
D. TraceSwitch
Ans: C

40. You are using Visual Studio .NET to develop a Web application for a large
video rental store. The titles, as well as other information about the store’s
videotapes, laser disks, DVDs, and audio books, are stored in a SQL Server
2000 database.
The store wants to allow visitors to its Web site to browse the list of titles
sorted in various ways, such as by medium (VHS, DVD, etc.., genre, director,
and so on. You have created a number of stored procedures to facilitate the
different ways of presenting the data.
Given an existing DataSet named dsVids and a Connection named conn, which
of the following code examples illustrates the correct way to call the stored
procedure named ListDVDTitles that returns the list of DVD titles
A. Dim daDVDList as New SqlDataAdapter(.
daDVDList.SelectCommand = New SqlCommand(.
daDVDList.SelectCommand.Connection = conn
daDVDList.SelectCommand.CommandText = “ListDVDTitles”
daDVDList.SelectCommand.CommandType = CommandType.StoredProcedure
daDVDList.Fill(dsVids, “Titles”.

B. Dim daDVDList as New SqlDataAdapter(.


daDVDList.SelectCommand = New StoredProcedure(.
daDVDList.SelectCommand.Connection = conn
daDVDList.SelectCommand.CommandText = “ListDVDTitles”
daDVDList.SelectCommand.CommandType = CommandType.SQLCommand
daDVDList.Fill(dsVids, “Titles”.
C. Dim daDVDList as New SqlDataAdapter(.
daDVDList.SelectCommand = New SqlCommand(.
daDVDList.SelectCommand.Connection = “ListDVDTitles”
daDVDList.SelectCommand.CommandType = CommandType.StoredProcedure
daDVDList.Fill(dsVids, “Titles”.

D. Dim daDVDList as New SqlDataAdapter(.


daDVDList.SelectCommand = New SqlCommand(.
daDVDList.SelectCommand.CommandText = “ListDVDTitles”
daDVDList.SelectCommand.CommandType = CommandType.StoredProcedure
daDVDList.Fill(dsVids, “Titles”.
Ans: A

43. The XSLT processor copies the elements of the stylesheet until it finds a
command in the format:
A. SELECT … FROM … WHERE.
B. {item, action}.
C. {for-each select}.
D. none.
Ans: B

44. What standard, protocol or language was generalized to become a standard


protocol for sending messages of any type, using any protocol?
A. SOAP
B. SGML
C. SQL
D. ADO
Answer: A

45. Which of the following statements is not true about XML Schemas:
A. They are used to define the content and structure of data.
B. They define a set of symbols and the relationships of those symbols.
C. They are themselves XML documents.
D. They have their own syntax.
Ans: D

46. The most popular way to materialize XML documents is to use:


A. DTD.
B. XSLT.
C. HTML.
D. SOAP.
Ans: B

47. With XML:


A. views are not limited to one multi-valued path only.
B. documents can automatically be generated from database data only.
C. database data can automatically be extracted from XML documents only.
D. With XML, all of the above are true.
Ans: D

48. To eliminate definition duplication, XML Schemas define:


A. an intersection table.
B. global elements.
C. a normalized definition table.
D. None of the above is correct.
Ans: B

48. What is not true about SOAP?


A. SOAP originally meant Simple Object Access Protocol.
B. SOAP was defined as an XML-based standard for providing remote
procedure calls over the Internet.
C. SOAP now is just a name, not an acronym
D. SOAP was an early form of XML.
Ans: D

49. XML Schemas consist of:


A. properties and methods.
B. elements and attributes.
C. structure and data.
D. tables and relationships.
Ans: B

50. The expression FOR XML RAW tells SQL Server to:
A. place the values of the columns as attributes in the resulting XML document.
B. place the values of the columns into elements rather than attributes.
C. place some columns into elements and others into attributes.
D. None of the above is correct.
Ans: A

51. ADO.NET provides the ability to create and process in-memory databases
called:
A. views.
B. relations.
C. tables.
D. datasets.
Ans: D

52. An XML component that defines the structure of a document is known as


a(n.:
A. DOCTYPE.
B. DTD.
C. #PCDATA.
D. HTML Stylesheet.
Ans: B

53. HTML is an application of a more robust document markup language called:


A. XHTML.
B. XML.
C. SGML.
D. None of the above is correct.
Ans: C

54. XSLT processors evaluate each statement in the context of the match that
has been made. That is, XSLT processors are:
A. context oriented.
B. procedural oriented.
C. object oriented.
D. relational oriented.
Ans: A

55. The DTD begins with the word:


A. #PCDATA.
B. XML.
C. DOCTYPE.
D. HTTPS.
Ans: C

56. What is not true about XML?


A. Web page display is the most important application of XML.
B. With XML, there is a clear separation between document structure, content
and materialization.
C. XML is more powerful than HTML.
D. XML documents have two sections.
Ans: A

57. What is not true about XSLT?


A. XSLT is a declarative transformation language.
B. XSLT uses a set of rules that govern how a document is to be materialized is
created.
C. XSLT uses a set of procedures that specify how a document is to be
programmed.
D. XSLT is used to transform the input document into another document.
Ans: C

58. If the XML data instance conforms to the DTD, the document is said to be:
A. type-invalid.
B. type-valid.
C. not-type-valid.
D. an HTML document.
Ans: B

59. The document that is used by XSLT to indicate how to transform the
elements of the XML document to another format is a(n.:
A. HTML page.
B. DOCTYPE procedure.
C. stylesheet.
D. stored procedure.
Ans: C

60. If an XML document does not have a DTD, then by definition it is:
A. not-type-valid.
B. type-valid.
C. an HTML document.
D. None of the above is correct.
Ans: A

61. Using Which Datasource Control Can Access Oracle DataBase ?


a. xmlDatasource
b. sqlDataSource
c. ObjectDatasource
d. All of the Aboove
Ans: C

62. How to get the current user Name ?


a. Identity.UserName
b. CurrentUser.Identity.Name
c. User.Identity.Name
d. Based on the Session Variable Name
Ans: C

63.Which is Incorrect ?
a. Session objecy is Private to user
b. Application Object is global
c. Caching can be global or Private
d. Application object vaues are accessed accross the application
Ans: C

64. Which is Correct ?


a. sql cache invalidation is a new feature in asp.net2.0
b. sql cache invalidation is an existing feature with enhancement
c. sql cache invalidation is an existing feature
d. sql cache invalidation is a bug in prior version
Ans: D

65.Which is correct ?
a. DataTable is member of a DataSet
b. DataTable is member of a System.Data
c. DataTable is member of a System.Data.SqlClient
d. Dataadapter
Ans: B

MVC Framework Interview Questions and Answers


1. What is MVC?
MVC is a framework methodology that divides an application’s implementation
into three component roles: models, views, and controllers.
Main components of an MVC application?
► M – Model
► V – View
► C – Controller

“Models” in a MVC based application are the components of the application


that are responsible for maintaining state. Often this state is persisted inside a
database (for example: we might have a Product class that is used to represent
order data from the Products table inside SQL).

“Views” in a MVC based application are the components responsible for


displaying the application’s user interface. Typically this UI is created off of the
model data (for example: we might create an Product “Edit” view that surfaces
textboxes, dropdowns and checkboxes based on the current state of a Product
object).

“Controllers” in a MVC based application are the components responsible for


handling end user interaction, manipulating the model, and ultimately choosing
a view to render to display UI. In a MVC application the view is only about
displaying information – it is the controller that handles and responds to user
input and interaction.

2. What does Model, View and Controller represent in an MVC application?


Model: Model represents the application data domain. In short the applications
business logic is contained with in the model.
View: Views represent the user interface, with which the end users interact. In
short the all the user interface logic is contained with in the UI.
Controller: Controller is the component that responds to user actions. Based
on the user actions, the respective controller, work with the model, and selects
a view to render that displays the user interface. The user input logic is
contained with in the controller.

3. In which assembly is the MVC framework defined?


System.Web.Mvc

4. What is the greatest advantage of using asp.net mvc over asp.net webforms?
It is difficult to unit test UI with webforms, where views in mvc can be very
easily unit tested.

5. Which approach provides better support for test driven development –


ASP.NET MVC or ASP.NET Webforms?
ASP.NET MVC
6. What is Razor View Engine?
Razor view engine is a new view engine created with ASP.Net MVC model using
specially designed Razor parser to render the HTML out of dynamic server side
code. It allows us to write Compact, Expressive, Clean and Fluid code with new
syntax to include server side code in to HTML.

7. What are the advantages of ASP.NET MVC?


Advantages of ASP.NET MVC:
1. Extensive support for TDD. With asp.net MVC, views can also be very easily
unit tested.
2. Complex applications can be easily managed
3. Separation of concerns. Different aspects of the application can be divided
into Model, View and Controller.
4. ASP.NET MVC views are light weight, as they don’t use viewstate.

8. Is it possible to unit test an MVC application without running the controllers


in an ASP.NET process?
Yes, all the features in an asp.net MVC application are interface based and
hence mocking is much easier. So, we don’t have to run the controllers in an
ASP.NET process for unit testing.

9. What is namespace of ASP.NET MVC?


ASP.NET MVC namespaces and classes are located in the System.Web.Mvc
assembly.
System.Web.Mvc namespace
Contains classes and interfaces that support the MVC pattern for ASP.NET Web
applications. This namespace includes classes that represent controllers,
controller factories, action results, views, partial views, and model binders.
System.Web.Mvc.Ajax namespace
Contains classes that support Ajax scripts in an ASP.NET MVC application. The
namespace includes support for Ajax scripts and Ajax option settings.
System.Web.Mvc.Async namespace
Contains classes and interfaces that support asynchronous actions in an
ASP.NET MVC application.
System.Web.Mvc.Html namespace
Contains classes that help render HTML controls in an MVC application. The
namespace includes classes that support forms, input controls, links, partial
views, and validation.

10. Is it possible to share a view across multiple controllers?


Yes, put the view into the shared folder. This will automatically make the view
available across multiple controllers.

11. What is the role of a controller in an MVC application?


The controller responds to user interactions, with the application, by selecting
the action method to execute and selecting the view to render.

12. Where are the routing rules defined in an asp.net MVC application?
In Application_Start event in Global.asax

13. Name a few different return types of a controller action method?


The following are just a few return types of a controller action method. In
general an action method can return an instance of a any class that derives
from ActionResult class.
1. ViewResult
2. JavaScriptResult
3. RedirectResult
4. ContentResult
5. JsonResult
14. What is the ‘page lifecycle’ of an ASP.NET MVC?
Following process are performed by ASP.Net MVC page:
1) App initialization
2) Routing
3) Instantiate and execute controller
4) Locate and invoke controller action
5) Instantiate and render view

15. What is the significance of NonActionAttribute?


In general, all public methods of a controller class are treated as action
methods. If you want prevent this default behavior, just decorate the public
method with NonActionAttribute.

16. What is the significance of ASP.NET routing?


ASP.NET MVC uses ASP.NET routing, to map incoming browser requests to
controller action methods. ASP.NET Routing makes use of route table. Route
table is created when your web application first starts. The route table is
present in the Global.asax file.

17. How route table is created in ASP.NET MVC?


When an MVC application first starts, the Application_Start() method is called.
This method, in turn, calls the RegisterRoutes() method. The RegisterRoutes()
method creates the route table.

18. What are the 3 segments of the default route, that is present in an ASP.NET
MVC application?
1st Segment – Controller Name
2nd Segment – Action Method Name
3rd Segment – Parameter that is passed to the action method
Example: http://google.com/search/label/MVC
Controller Name = search
Action Method Name = label
Parameter Id = MVC

19. ASP.NET MVC application, makes use of settings at 2 places for routing to
work correctly. What are these 2 places?
1. Web.Config File : ASP.NET routing has to be enabled here.
2. Global.asax File : The Route table is created in the application Start event
handler, of the Global.asax file.

20. What is the adavantage of using ASP.NET routing?


In an ASP.NET web application that does not make use of routing, an incoming
browser request should map to a physical file. If the file does not exist, we get
page not found error.
An ASP.NET web application that does make use of routing, makes use of
URLs that do not have to map to specific files in a Web site. Because the URL
does not have to map to a file, you can use URLs that are descriptive of the
user’s action and therefore are more easily understood by users.

21. What are the 3 things that are needed to specify a route?
1. URL Pattern – You can include placeholders in a URL pattern so that variable
data can be passed to the request handler without requiring a query string.
2. Handler – The handler can be a physical file such as an .aspx file or a
controller class.
3. Name for the Route – Name is optional.

22. Is the following route definition a valid route definition?


{controller}{action}/{id}
No, the above definition is not a valid route definition, because there is no
literal value or delimiter between the placeholders. Therefore, routing cannot
determine where to separate the value for the controller placeholder from the
value for the action placeholder.

23. What is the use of the following default route?


{resource}.axd/{*pathInfo}
This route definition, prevent requests for the Web resource files such as
WebResource.axd or ScriptResource.axd from being passed to a controller.

24. What is the difference between adding routes, to a webforms application


and to an mvc application?
To add routes to a webforms application, we use MapPageRoute() method of
the RouteCollection class, where as to add routes to an MVC application we
use MapRoute() method.

25. How do you handle variable number of segments in a route definition?


Use a route with a catch-all parameter. An example is shown below. * is
referred to as catch-all parameter.
controller/{action}/{*parametervalues}

26. What are the 2 ways of adding constraints to a route?


1. Use regular expressions
2. Use an object that implements IRouteConstraint interface

27. Give 2 examples for scenarios when routing is not applied?


1. A Physical File is Found that Matches the URL Pattern – This default
behaviour can be overriden by setting the RouteExistingFiles property of the
RouteCollection object to true.
2. Routing Is Explicitly Disabled for a URL Pattern – Use the
RouteCollection.Ignore() method to prevent routing from handling certain
requests.

28. What is the use of action filters in an MVC application?


Action Filters allow us to add pre-action and post-action behavior to controller
action methods.

29. If I have multiple filters implemented, what is the order in which these filters
get executed?
1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters

30. What are the different types of filters, in an asp.net mvc application?
1. Authorization filters
2. Action filters
3. Result filters
4. Exception filters

31. Give an example for Authorization filters in an asp.net mvc application?


1. RequireHttpsAttribute
2. AuthorizeAttribute

32. Which filter executes first in an asp.net mvc application?


Authorization filter

33- What are the levels at which filters can be applied in an asp.net mvc
application?
1. Action Method
2. Controller
3. Application

34. Is it possible to create a custom filter?


Yes

35. What filters are executed in the end?


Exception Filters

36. Is it possible to cancel filter execution?


Yes

37. What type of filter does OutputCacheAttribute class represents?


Result Filter

38. What are the 2 popular asp.net mvc view engines?


1. Razor
2. .aspx

39. What is difference between Viewbag and Viewdata in ASP.NET MVC?


The basic difference between ViewData and ViewBag is that in ViewData
instead creating dynamic properties we use properties of Model to transport
the Model data in View and in ViewBag we can create dynamic properties
without using Model data.

40. What symbol would you use to denote, the start of a code block in razor
views?
@

41. What symbol would you use to denote, the start of a code block in aspx
views?
<%= %>

In razor syntax, what is the escape sequence character for @ symbol?


The escape sequence character for @ symbol, is another @ symbol

42. When using razor views, do you have to take any special steps to protect
your asp.net mvc application from cross site scripting (XSS) attacks?
No, by default content emitted using a @ block is automatically HTML encoded
to protect from cross site scripting (XSS) attacks.

43. When using aspx view engine, to have a consistent look and feel, across all
pages of the application, we can make use of asp.net master pages. What is
asp.net master pages equivalent, when using razor views?

To have a consistent look and feel when using razor views, we can make use of
layout pages. Layout pages, reside in the shared folder, and are named as
_Layout.cshtml

44. What are sections?


Layout pages, can define sections, which can then be overriden by specific
views making use of the layout. Defining and overriding sections is optional.

45. What are the file extensions for razor views?


1. .cshtml – If the programming lanugaue is C#
2. .vbhtml – If the programming lanugaue is VB

46. How do you specify comments using razor syntax?


Razor syntax makes use of @* to indicate the begining of a comment and *@ to
indicate the end.
47. What is Routing?
A route is a URL pattern that is mapped to a handler. The handler can be a
physical file, such as an .aspx file in a Web Forms application. Routing module
is responsible for mapping incoming browser requests to particular MVC
controller actions.

48. Is it possible to combine ASP.NET webforms and ASP.MVC and develop a


single web application?
Yes, it is possible to combine ASP.NET webforms and ASP.MVC and develop a
single web application.

49. How do you avoid XSS Vulnerabilities in ASP.NET MVC?


Use the syntax in ASP.NET MVC instead of using .net framework 4.0.

50. Explain the new features added in version 4 of MVC (MVC4)?


Following are features added newly –
Mobile templates:
Added ASP.NET Web API template for creating REST based services.
Asynchronous controller task support.
Bundling the java scripts.
Segregating the configs for MVC routing, Web API, Bundle etc.

51. Can you explain the page life cycle of MVC?


Below are the processed followed in the sequence –

App initialization
Routing
Instantiate and execute controller
Locate and invoke controller action
Instantiate and render view.

52. What are the advantages of MVC over ASP.NET?


Provides a clean separation of concerns among UI (Presentation layer), model
(Transfer objects/Domain Objects/Entities) and Business Logic (Controller).
Easy to UNIT Test.
Improved reusability of model and views. We can have multiple views which
can point to the same model and vice versa.
Improved structuring of the code.

53. What is Separation of Concerns in ASP.NET MVC?


It’s is the process of breaking the program into various distinct features which
overlaps in functionality as little as possible. MVC pattern concerns on
separating the content from presentation and data-processing from content.

54. What is Razor View Engine?


Razor is the first major update to render HTML in MVC 3. Razor was designed
specifically for view engine syntax. Main focus of this would be to simplify and
code-focused templating for HTML generation. Below is the sample of using
Razor:
@model MvcMusicStore.Models.Customer
@{ViewBag.Title = “Get Customers”;}
@Model.CustomerName

55. What is the meaning of Unobtrusive JavaScript?


This is a general term that conveys a general philosophy, similar to the term
REST (Representational State Transfer). Unobtrusive JavaScript doesn’t
intermix JavaScript code in your page markup.
Eg : Instead of using events like onclick and onsubmit, the unobtrusive
JavaScript attaches to elements by their ID or class based on the HTML5 data-
attributes.
56. What is the use of ViewModel in MVC?
ViewModel is a plain class with properties, which is used to bind it to strongly
typed view. ViewModel can have the validation rules defined for its properties
using data annotations.

57. What you mean by Routing in MVC?


Routing is a pattern matching mechanism of incoming requests to the URL
patterns which are registered in route table. Class – “UrlRoutingModule” is
used for the same process.

58. What are Actions in MVC?


Actions are the methods in Controller class which is responsible for returning
the view or json data. Action will mainly have return type – “ActionResult” and
it will be invoked from method – “InvokeAction()” called by controller.

59. What is Attribute Routing in MVC?


ASP.NET Web API supports this type routing. This is introduced in MVC5. In
this type of routing, attributes are being used to define the routes. This type of
routing gives more control over classic URI Routing. Attribute Routing can be
defined at controller level or at Action level like –
[Route(“{action = TestCategoryList}”)] – Controller Level
[Route(“customers/{TestCategoryId:int:min(10)}”)] – Action Level

60. How to enable Attribute Routing?


Just add the method – “MapMvcAttributeRoutes()” to enable attribute routing
as shown below
public static void RegistearRoutes(RouteCollection routes)
{
routes.IgnoareRoute(“{resource}.axd/{*pathInfo}”);
//enabling attribute routing
routes.MapMvcAttributeRoutes();
//convention-based routing
routes.MapRoute
(
name: “Default”,
url: “{controller}/{action}/{id}”,
defaults: new { controller = “Customer”, action = “GetCustomerList”, id =
UrlParameter.Optional }
);
}

61. Explain JSON Binding?


JavaScript Object Notation (JSON) binding support started from MVC3 onwards
via the new JsonValueProviderFactory, which allows the action methods to
accept and model-bind data in JSON format. This is useful in Ajax scenarios
like client templates and data binding that need to post data back to the server.

62. Explain Dependency Resolution?


Dependency Resolver again has been introduced in MVC3 and it is greatly
simplified the use of dependency injection in your applications. This turn to be
easier and useful for decoupling the application components and making them
easier to test and more configurable.

63. Explain Bundle.Config in MVC4?


“BundleConfig.cs” in MVC4 is used to register the bundles by the bundling and
minification system. Many bundles are added by default including jQuery
libraries like – jquery.validate, Modernizr, and default CSS references.

64. How route table has been created in ASP.NET MVC?


Method – “RegisterRoutes()” is used for registering the routes which will be
added in “Application_Start()” method of global.asax file, which is fired when
the application is loaded or started.

65. Which are the important namespaces used in MVC?


Below are the important namespaces used in MVC –
System.Web.Mvc
System.Web.Mvc.Ajax
System.Web.Mvc.Html
System.Web.Mvc.Async

67. What is ViewData?


Viewdata contains the key, value pairs as dictionary and this is derived from
class – “ViewDataDictionary“. In action method we are setting the value for
viewdata and in view the value will be fetched by typecasting.

68. What is the difference between ViewBag and ViewData in MVC?


ViewBag is a wrapper around ViewData, which allows to create dynamic
properties. Advantage of viewbag over viewdata will be –

In ViewBag no need to typecast the objects as in ViewData.


ViewBag will take advantage of dynamic keyword which is introduced in
version 4.0. But before using ViewBag we have to keep in mind that ViewBag is
slower than ViewData.

69. Can you specify different types of filters in ASP.Net MVC application?
1) Authorization filters (IAuthorizationFilter)
2) Action filters (IActionFilter)
3) Result filters (IResultFilter)
4) Exception filters (IExceptionFilter)

70. If you have already implemented different filters then what will be order of
these filters?
1) Authorization filters
2) Action filters
3) Response filters
4) Exception filters

71. What are the advantages of using ASP.NET routing?


In an ASP.NET web application that does not make use of routing, an incoming
browser request should map to a physical file. If the file does not exist, we get
page not found error.
An ASP.NET web application that does make use of routing, makes use of
URLs that do not have to map to specific files in a Web site. Because the URL
does not have to map to a file, you can use URLs that are descriptive of the
user's action and therefore are more easily understood by users.

72. What is the difference between MVC (Model View Controller) and MVP
(Model View Presenter)?
MVC controller handles all the requests, MVP handles as the handler and also
handles the all requests as well.

73. Can we use third party View Engine using ASP.Net MVC Engine ?
Yes, below are the top five alternative ASP.Net MVC View Engines.
1. Spark (Castle MonoRail framework projects), Open Sourced, it is popular as
MVCContrib library.
2. NHaml works like inline page templating.
3. NDjango uses F# Language.
4. Hasic uses VB.Net, XML.
5. Bellevue for ASP.NEt view, It respects HTML class first.
74. What is scaffolding using ASP.Net MVC Engine?
Scaffolding helps us to write CRUD operations blend using Entity Framework, It
helps developer to write down simply even yet complex business logic.

75. What is life cycle in ASP.Net MVC Engine?


Step 1: Fill Route (Global.asax file will hit first).
Step 2: Fetch Route: It will gether information about controller and action to
invoke.
Step 3: Request context
Step 4: Controller instance: it calls Controller class and method.
Step 5: Executing Action: It determines which action to be executed
Step 6: Result (View): Now Action method executed and returns back response
to view in differentiating forms like Json, View Result, File Result etc.

76. What is the significance of ASP.NET routing?


Default Route Name:
“{controller}/{action}/{id}”, // URL with parameters
By default routing is defined under Global.asax file. MVC ASP.Net uses routing
to map between incoming browser request to controller action methods.

77. Can be it possible to share single view across multiple controllers in MVC?
We can put the view under shared folder, it will automatically view the across
the multiple controllers.

78. Can you list the main types of result using ASP.Net MVC?
There are total 10 main types of result, ActionResult is main type and others
are sub types of results as listed below:
• System.Web.Mvc.ActionResult
• System.Web.Mvc.ContentResult
• System.Web.Mvc.EmptyResult
• System.Web.Mvc.FileResult
• System.Web.Mvc.HttpStatusCodeResult
• System.Web.Mvc.JavaScriptResult
• System.Web.Mvc.JsonResult
• System.Web.Mvc.RedirectResult
• System.Web.Mvc.RedirectToRouteResult
• System.Web.Mvc.ViewResultBase

79. What are Model Binders in ASP.Net MVC?


For Model Binding we will use class called : “ModelBinders”, which gives
access to all the model binders in an application. We can create a custom
model binders by inheriting “IModelBinder”.

80. How we can handle the exception at controller level in ASP.Net MVC?
Exception Handling is made simple in ASP.Net MVC and it can be done by just
overriding “OnException” and set the result property of the filtercontext object
(as shown below) to the view detail, which is to be returned in case of
exception.

protected overrides void OnException(ExceptionContext filterContext)


{
}

81. What are Scaffold templates in ASP.Net MVC?


Scaffolding in ASP.NET ASP.Net MVC is used to generate the Controllers,Model
and Views for create, read, update, and delete (CRUD) functionality in an
application. The scaffolding will be knowing the naming conventions used for
models and controllers and views.
82. Does Tempdata hold the data for other request in ASP.Net MVC?
If Tempdata is assigned in the current request then it will be available for the
current request and the subsequent request and it depends whether data in
TempData read or not. If data in Tempdata is read then it would not be available
for the subsequent requests.

83. Explain Keep method in Tempdata in ASP.Net MVC?


As explained above in case data in Tempdata has been read in current request
only then “Keep” method has been used to make it available for the
subsequent request.

@TempData[“TestData”];
TempData.Keep(“TestData”);

84. Explain Peek method in Tempdata in ASP.Net MVC?


Similar to Keep method we have one more method called “Peek” which is used
for the same purpose. This method used to read data in Tempdata and it
maintains the data for subsequent request.
string A4str = TempData.Peek(“TT”).ToString();

85. What is Area in ASP.Net MVC?


Area is used to store the details of the modules of our project. This is really
helpful for big applications, where controllers, views and models are all in main
controller, view and model folders and it is very difficult to manage.

86. How we can register the Area in ASP.Net MVC?


When we have created an area make sure this will be registered in
“Application_Start” event in Global.asax. Below is the code snippet where area
registration is done :
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
}

87. What are child actions in ASP.Net MVC?


To create reusable widgets child actions are used and this will be embedded
into the parent views. In ASP.Net MVC Partial views are used to have reusability
in the application. Child action mainly returns the partial views.

88. How we can invoke child actions in ASP.Net MVC?


“ChildActionOnly” attribute is decorated over action methods to indicate that
action method is a child action. Below is the code snippet used to denote the
child action :
[ChildActionOnly]
public ActionResult MenuBar()
{
//Logic here
return PartialView();
}

89. What is Dependency Injection in ASP.Net MVC?


it’s a design pattern and is used for developing loosely couple code. This is
greatly used in the software projects. This will reduce the coding in case of
changes on project design so this is vastly used.

90. Explain the advantages of Dependency Injection (DI) in ASP.Net MVC?


Below are the advantages of DI :
Reduces class coupling
Increases code reusing
Improves code maintainability
Improves application testing
yTDD is a methodology which says, write your tests first before you write your
code. In TDD, tests drive your application design and development cycles. You
do not do the check-in of your code into source control until all of your unit
tests pass.

92. Explain the tools used for unit testing in ASP.Net MVC?
Below are the tools used for unit testing :
NUnit
xUnit.NET
Ninject 2
Moq

93. What is Representational State Transfer (REST) mean?


REST is an architectural style which uses HTTP protocol methods like GET,
POST, PUT, and DELETE to access the data. ASP.Net MVC works in this style.
In ASP.Net MVC 4 there is a support for Web API which uses to build the
service using HTTP verbs.

94. How to use Jquery Plugins in ASP.Net MVC validation?


We can use dataannotations for validation in ASP.Net MVC. If we want to use
validation during runtime using Jquery then we can use Jquery plugins for
validation. Eg: If validation is to be done on customer name textbox then we
can do as :
$(‘#CustomerName’).rules(“add”, {
required: true,
minlength: 2,
messages: {
required: “Please enter name”,
minlength: “Minimum length is 2”
}
});

95. How we can multiple submit buttons in ASP.Net MVC?


Below is the scenario and the solution to solve multiple submit buttons issue.
Scenario :
@using (Html.BeginForm(“MyTestAction”,”MyTestController”)
{
<input type=”submit” value=”MySave” />
<input type=”submit” value=”MyEdit” />
} Solution :
Public ActionResult MyTestAction(string submit) //submit will have value either
“MySave” or “MyEdit”
{
// Write code here
}

96. What are the differences between Partial View and Display Template and
Edit Templates in ASP.Net MVC?
Display Templates : These are model centric. Meaning it depends on the
properties of the view model used. It uses convention that will only display like
divs or labels.
Edit Templates : These are also model centric but will have editable controls
like Textboxes.
Partial View : These are view centric. These will differ from templates by the
way they render the properties (Id’s) Eg : CategoryViewModel has Product
class property then it will be rendered as Model.Product.ProductName but in
case of templates if we CategoryViewModel has List then @Html.DisplayFor(m
=> m.Products) works and it renders the template for each item of this list.
97. Can I set the unlimited length for “maxJsonLength” property in config?
No. We can’t set unlimited length for property maxJsonLength. Default value is
– 102400 and maximum value what we can set would be : 2147483644.

98. Can I use Razor code in Javascript in ASP.Net MVC?


Yes. We can use the razor code in javascript in cshtml by using <text> element.

< script type=”text/javascript”>


@foreach (var item in Model) {
< text >
//javascript goes here which uses the server values
< text >
}
< script>

99. How can I return string result from Action in ASP.Net MVC?
Below is the code snippet to return string from action method :
public ActionResult TestAction() {
return Content(“Hello Test !!”);
}

100. How to return the JSON from action method in ASP.Net MVC?
Below is the code snippet to return string from action method :
public ActionResult TestAction() {
return JSON(new { prop1 = “Test1”, prop2 = “Test2” });
}

ASP.NET MVC interview questions with answers


1. What is ASP.Net MVC
The ASP.Net MVC is the framework provided by Microsoft to achieve
separation of concerns that leads to easy maintainability of the application.
Model is supposed to handle data related activity
View deals with user interface related work
Controller is meant for managing the application flow by communicating
between Model and View.

2. Why to use ASP.Net MVC


The strength of MVC (i.e. ASP.Net MVC) is listed below, that will answer this
question
MVC reduces the dependency between the components; this makes your code
more testable.
MVC does not recommend use of server controls, hence the processing time
required to generate HTML response is drastically reduced.
The integration of java script libraries like jQuery, Microsoft MVC becomes easy
as compared to Webforms approach.

3. What do you mean by Razor


The Razor is the new View engine introduced in MVC 3.0.
The View engine is responsible for processing the view files [e.g. .aspx,
.cshtml] in order to generate HTML response.
The previous versions of MVC were dependent on ASPX view engine.

4. Can we use ASPX view engine in latest versions of MVC


Yes. The Recommended way is to prefer Razor View

5. What are the benefits of Razor View?


The syntax for server side code is simplified
The length of code is drastically reduced
Razor syntax is easy to learn and reduces the complexity
6. What is the extension of Razor View file?
.cshtml (for c#) and .vbhtml (for vb)

7. How to create a Controller in MVC


Create a simple class and extend it from Controller class. The bare minimum
requirement for a class to become a controller is to inherit it from
ControllerBase is the class that is required to inherit to create the controller but
Controller class inherits from ControllerBase.

8. How to create an Action method in MVC


Add a simple method inside a controller class with ActionResult return type.

9. How to access a view on the server


The browser generates the request in which the information like Controller
name, Action Name and Parameters are provided, when server receives this
URL it resolves the Name of Controller and Action, after that it calls the
specified action with provided parameters. Action normally does some
processing and returns the ViewResult by specifying the view name (blank
name searches according to naming conventions).

10. What is the default Form method (i.e. GET, POST) for an action method
GET. To change this you can add an action level attribute e.g [HttpPost]

11. What is a Filter in MVC?


When user (browser) sends a request to server an action method of a controller
gets invoked; sometimes you may require executing a custom code before or
after action method gets invoked, this custom code is called as Filter.

12. What are the different types of Filters in MVC?


a. Authorization filter
b. Action filter
c. Result filter
d. Exception filter
[Do not forget the order mentioned above as filters gets executed as per above
mentioned sequence]

13. Explain the use of Filter with an example?


Suppose you are working on a MVC application where URL is sent in an
encrypted format instead of a plain text, once encrypted URL is received by
server it will ignore action parameters because of URL encryption.
To solve this issue you can create global action filter by overriding
OnActionExecuting method of controller class, in this you can extract the
action parameters from the encrypted URL and these parameters can be set on
filterContext to send plain text parameters to the actions.

14. What is a HTML helper?


A HTML helper is a method that returns string; return string usually is the
HTML tag. The standard HTML helpers (e.g. Html.BeginForm(),Html.TextBox())
available in MVC are lightweight as it does not rely on event model or view
state as that of in ASP.Net server controls.

You might also like