ASP.NET MCQs

ASP.NET MCQs

The following ASP.NET MCQs have been compiled by our experts through research, in order to test your knowledge of the subject of ASP.NET. We encourage you to answer these multiple-choice questions to assess your proficiency.
Please continue by scrolling down.

1: Where are private assemblies stored in ASP.NET?

A.   root directory of bootable drive

B.   windows directory

C.   application root directory

D.   application / bin directory

2: We can manage states in asp.net application using

A.   Session Objects

B.   Application Objects

C.   Viewstate

D.   (all of these)

3: Which of these forms is used in ASP.NET?

A.   Winforms

B.   Webforms

C.   HTMLForms

4: What is the extension of a web user control file?

A.   .Ascx

B.   .Asmx

C.   .Aspx

5: Which of the following is a property all the ASP.NET controls have?

A.   runat

B.   text

C.   name

D.   bgcolor

6: What is ASP.Net

A.   Programming Language

B.   Server Side Technology

7: Which method of the ServiceController class will allow you to send a command to the service?

A.   ExecuteCommand()

B.   Pause()

C.   Start()

D.   Stop()

8: Can you set which type of comparison you want to perform by the CompareValidator control?

A.   Yes

B.   No

9: Which version of ASP .NET MVC has built-in support for mobile targeting?

A.   MVC 4

B.   MVC 2

C.   MVC 3

D.   MVC 1

10: Which of the following ASP.NET directories stores class files (.cs) by default?

A.   Bin

B.   App_Code

C.   App_GlobalResources

D.   App_Data

11: Which HTML control property should be set to access control from code behind?

A.   Runat = "Server"

B.   ID = "TextBox2"

C.   ClientID = "TextBox1"

D.   RunatServer = "True"

12: Which attribute must be set on the validator control for the validator to work?

A.   validatecontrol

B.   ControlToValidate

C.   controltobind

D.   validate

13: Which of the following file types is associted with ASP.NET User controls?

A.   .ascx

B.   .aspx

C.   .asax

D.   .asmx

14: In Asp.Net Server.MapPath(".") points to which location

A.   it will not point to any location

B.   points to the location where your project stored

C.   there is no such function in asp.net

D.   points to C:\\My Documents\Microsoft Visual Studio folder

15: Which of the following controls is used to validate that two fields are equal?

A.   Equals() method

B.   RegularExpressionValidator

C.   CompareValidator

D.   Required Field Validator

16: In which event are the controls fully loaded?

A.   Page.Init()

B.   Page.Load()

C.   Page.OnLoad()

D.   Page.PreInit()

17: ASP.NET stores membership, role management, and profile information in which database?

A.   aspdotnetdatabaase

B.   aspnetdb

C.   aspdotnetdb

D.   netdb

18: Which of the following is not a .NET compatible language?

A.   VB.NET

B.   Managed C++

C.   Java

D.   C#, J#

E.   COBOL.NET, Perl.NET

19: In ASP.Net, session is maintained using the methods:

A.   Only Session State Service

B.   (all of these)

C.   Only In-Process storage

D.   Only SQL Server

20: What is default timeout of session in asp.net?

A.   20 ns

B.   20 min

C.   10ns

D.   10min

E.   1 hr

21: How do you enable impersonation in the web.config file?

A.   <identity impersonate = "true" />

B.   <setImpersonate = "true" />

C.   <impersonate = "true" />

D.   <identity setImpersonate = "true" />

22: Where is the ViewState information stored?

A.   in cookies

B.   in session variables

C.   in the HTML hidden fields.

D.   query string

E.   in database

23: The first method that is executed in the Page life cycle in ASP.NET is:

A.   Page.Load

B.   PreLoad

C.   Init

D.   PreInit

24: Can Web API be hosted in its own process without IIS?

A.   No

B.   Yes

25: Which of the following contains one or more variables that are accessed through sequential indices?

A.   Delegates

B.   Arrays

C.   Nullable Types

D.   Indexers

26: Which of the following statements best describes setting up an async page in .NET 4.5?

A.   async=true on page directive, RegisterAsyncTask in page load and async method

B.   async method

C.   TaskFactory.StartNew(method1)

D.   async=true on page directive

27: How do you make a controller action async?

A.   return an async Task from controller action while awaiting within the method

B.   return an async Task from controller action while awaiting within the method

C.   return an async Task from controller action

D.   Register async controller action in Global.asax

28: Can MVC, Web Forms and Web API be mixed in the same project?

A.   Only in .NET 4.5

B.   Only MVC and Web Forms, not Web API

C.   Yes

D.   No

29: How can an MVC View be protected from CSRF?

A.   not possible

B.   @Html.AntiForgeryToken() in View

C.   @Html.AntiForgeryToken() in View and ValidateAntiForgeryToken attribute on controller action

D.   Web.Config app setting AntiForgeryToken true

30: Which formats can Web API work with?

A.   XML

B.   All of these

C.   xVx

D.   ATOM Pub

31: True or False: It is true that lines are reference type?

A.   False

B.   True

32: What method(s) must be used with the Application object to ensure that only one process accesses a variable at a time?

A.   ThreadLock

B.   Synchronize()

C.   Lock() and UnLock()

33: The property used to access user's locale information is:

A.   System.Web.UI.Page.Culture

B.   System.Web.Locale

C.   System.Web.UI.Page.User

D.   System.Web.UI.Page.Locale

34: True or False: Without Web.config file application will not compile or Run.

A.   True

B.   False

35: _______ is a special subfolder within the windows folder that stores the shared .NET component?

A.   Root

B.   /bin

C.   GAC

36: In LINQ what is the difference in .Ancestor and .Parent?

A.   None of the above

B.   Parent is the immediate node a level above, Ancestors is all nodes all levels above.

C.   Parent is the immediate node a level above, Ancestors is all nodes above and below.

D.   Parent is the immediate node below, Ancestors is all nodes above and below.

37: You are developing ASP.NET templated server control. You need to ensure that a new ID namespace is created within the page control hierarchy when the control is added to the page. Which interface should you implement on the control?

A.   INamingContainer

B.   IExtenderCtonrol

C.   IDataKeysControl

D.   IDataItemContainer

38: Can you run a web application without the web.config file?

A.   Runtime error

B.   Yes

C.   It will not compile if there is no web.config file

D.   No

39: In the following example, is viewstate being set? (Test.aspx - viewstate enabled) (Test.aspx.cs) protected override void OnLoad(EventArgs args) { this.LabelTest.Text = “changed”; base.OnLoad(e); }

A.   Only in .NET 4+

B.   No

C.   Only if LabelTest.Text is changed in following events before PreRender

D.   Yes

40: Which one is the first step in Asp.Net MVC request cycle.

A.   Controller

B.   Mvc Handler

C.   Routing

D.   View Engine

E.   Action Execution

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

A.   Session Object

B.   InProcess

C.   StateServer

42: Which two new properties are added in ASP.NET 4.0 Page class?

A.   Culture and Locale

B.   Keyword and Description

C.   MetaKeyword and MetaDescription

D.   Culture and Description

43: Contents of assembly file can be investigated using

A.   ILDASM.dll

B.   ILDASM.inc

C.   ILDASM.exe

D.   ILDASM.aspx

44: In which of the following SessionState Modes the Session_End event fires?

A.   SQL Server

B.   Inproc

C.   None

D.   StateServer

45: How can you disable client-side validation in ASP.NET?

A.   By setting the EnableClientScript property to false

B.   by setting CauseValidation to false

C.   By setting ValidateClientScript to false

D.   By setting EnableScripting to false

E.   By setting ValidateScripting to false

46: When would WCF be a better solution than Web API?

A.   Need for REST

B.   Need for XML

C.   Need for metadata

D.   Need for SOAP

47: which of the following is not ASP.NET directives?

A.   web

B.   page

C.   import

D.   register

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

A.   20

B.   1

C.   more than 30

D.   10

49: I have a property in my code-behind get { return (Custom)Session["Custom"]; } set { Session["Custom"] = value; } and I receive a serialization error What are the possible solutions?

A.   Change sessionstate mode to InProc

B.   Change the property type to HashSet instead of Custom

C.   Add the Serializable attribute to Custom class

D.   All of these will work

50: Which property is used to retrieve a username in Windows Authentication?

A.   System.Environment.UserName

B.   System.UserName

C.   System.Environment.User

D.   System.Environment.GetUserName

51: Which method has been introduced in ASP.NET 4.0 to redirect a page permanently?

A.   RedirectPermanent() method

B.   Page.Redirect(true) method

C.   PermanentRedirect() method

D.   Redirect(true) method

52: What are the three IIS isolation levels?

A.   Base, Custom and Enhanced

B.   Base, Custom and High

C.   Pooled, Non pooled, Not set

D.   Low, Medium and High

53: What is wrong with this code? string email = emailTextbox; string SQL = "select * from users where username = "+email+" "; SqlCommand myCommand = new SQLCommand(SQL, myConnection) try { myConnection.Open(); SqlDataReader myReader=myCommand.ExecuteReader(); if (myReader.Read()) { ...

A.   the string email will not have the right value.

B.   There is nothing wrong in this code.

C.   the string email will not have the right value and the SQL is subject to injection attacks.

D.   the SQL is subject to injection attacks.

E.   a SqlDataReader can't be instantiated from a SqlCommand object.

54: Which of the following events are correctly ordered according to the Application lifecycle?

A.   BeginRequest, AuthenticateRequest, AuthorizeRequest, AcquireRequestState, ResolveRequestCache, ProcessRequest, UpdateRequestCache, ReleaseRequestState, EndRequest.

B.   BeginRequest, ResolveRequestCache, AuthenticateRequest, AuthorizeRequest, AcquireRequestState, ProcessRequest, ReleaseRequestState, UpdateRequestCache, EndRequest.

C.   BeginRequest, AuthorizeRequest, AuthenticateRequest, ResolveRequestCache, AcquireRequestState, ProcessRequest, ReleaseRequestState, UpdateRequestCache, EndRequest.

D.   BeginRequest, AuthenticateRequest, AuthorizeRequest, ResolveRequestCache, AcquireRequestState, ProcessRequest, ReleaseRequestState, UpdateRequestCache, EndRequest.

55: What is correct Syntax for applying FAViCON ICON to your web page.

A.   <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>

B.   <link rel="icon" href="/favicon.ico" type="image/x-icon"/>

C.   <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/> <link rel="icon" href="/favicon.ico" type="image/x-icon"/>

56: Which of the following statements is true about the GridView in .NET 4.5?

A.   Can only be bound to a data sources or objects that are data bound in code behind

B.   Strongly typed object binding

C.   Uses CSS div’s instead of html table based layout

D.   Uses AJAX functionality by default

57: How can Web API OData support be implemented?

A.   Controller extends ODataController

B.   Return IQueryable or IEnumerable

C.   Controller extends EntitySetController<T>

D.   All of these

58: False or True? Using DateTime.Now is much faster than using the Timestamp property

A.   True

B.   False

59: In ASP.NET if you want to allows page developers a way to specify static connections in a content page then the class used is

A.   System.Activator

B.   ProxyWebPartManager

C.   None of the Above

D.   WebPartManager

60: Which of the following is not a Web Form Event in ASP.NET: Page_Dispose Page_Error Page_AbortTransaction Page_CommitTransaction

A.   None of these

B.   Page_Error

C.   All of these

D.   Page_Dispose

61: What can we specify in the web.config to apply Themes to an ASP.NET application?

A.   <pages applyTheme="Windows7" />

B.   <pages theme="Windows7" />

C.   <pages themesEnabled="true" />

D.   <pages theme="true" />

62: Under what condition(s) should a controller action be made async?

A.   IO intensive

B.   All controller actions should be made async

C.   CPU intensive

D.   CPU & IO intensive

63: Which of the following locking techniques is considered speculative?

A.   SpinLock

B.   lock

C.   SpinWait

D.   MemoryBarrier

64: What are the strategies for partitioning threads in a PLINQ query?

A.   IEnumerable or IQueryable

B.   Auto or manual

C.   Chunked, ranged or hashed

D.   AsParallel().WithDegreeOfParallelism()

65: How do you turn off cookies for a page?

A.   Set CookieEnabled = false in all pages

B.   Set IsCookieEnabled to false in all pages

C.   Set Cookie to false in all pages

D.   Set Cookie.Discard property to true

66: How does Web API OData support partial updates?

A.   PartialUpdatesEnabled in global.asax.cs

B.   PartialUpdatesEnabled setting in web.config

C.   Delta parameter in controller action

D.   Patch parameter in controller action

A.   None of these

B.   Threading

C.   Parallel Programming

D.   Multi-core Processors

68: Which of the following statements is true?

A.   IEnumerable is thread safe by default because each iterator gets an IEnumerator

B.   IEnumerable is a push based sequence

C.   IEnumerable is both push and pull based

D.   IEnumerable is a pull based sequence

69: Which one is faster way of resolving paths?

A.   Request.PhysicalApplicationPath

B.   Server.MapPath('~/')

70: The property used to set absolute cache expiration in ASP.NET is:

A.   Cache.SetAbsoluteExpiration

B.   Cache.AbsoluteExpiration

C.   Cache.NoExpiration

D.   Cache.NoSlidingExpiration

71: When decorating a function with async, what is the appropriate return type?

A.   Task<object>

B.   List<Object>

C.   Task<>

D.   async

72: Which method do you use to enforce garbage collection in .NET?

A.   System.Data.Annotation()

B.   System.GC.Collect() method

C.   System.Collect.GC() method

A.   Relative

B.   Absolute

74: If a developer of ASP.NET defines style information in a common location. Then that location is called as

A.   Master Page

B.   Theme

C.   All of them

D.   Customization

E.   None of the Above

75: Can we access and change value of a control which is defined in a Master page from the child page?

A.   False

B.   True

76: Which type is used to manage client-side state?

A.   Query Strings

B.   Hidden fields

C.   Cookies

D.   All these

E.   Viewstate

77: which is the first event which gets triggers or fires in an Aspx Page?

A.   Page_Load()

B.   Page_Init()

78: Which control does not have any event?

A.   ImageButton

B.   LinkButton

C.   Button

D.   Image

79: What method is used to explicitly kill a users session?

A.   Session.Killer();

B.   Session.Abandon();

C.   Session.Abort();

80: Can we have multiple web.config files in a web application?

A.   True

B.   False

81: Which of the following are true about System.Security.Cryptography under version 3.5 of the framework?

A.   Cryptography Next Generation (CNG) classes are supported on XP andVista systems.

B.   The System.Security.Cryptography.AesManaged class allows custom block size, iteration counts and feedback modes to support any Rijndael based encryption.

C.   Support is provided for the 'Suite B' set of cryptographic algorithms as specified by the National Security Agency (NSA).

D.   All of the above

82: Which of the following differentiates a UserControl from a Custom Server control?

A.   UserControl can directly express rendering information via markup; a CustomServer control can not.

B.   UserControl can make use of script based validation; a Custom Server control cannot.

C.   UserControl can represent complete compositate hierarchy; a Custom Server control cannot.

D.   UserControl does not require the use of the @Register directive; a Custom Server control does require it.

83: In the following web.config directive: Is "Off" case-sensitive?

A.   No

B.   Yes

84: Which of the following is used to disable client side script in validators?

A.   Set EnableClientScript property to false.

B.   Set DisableClientScript property to true.

C.   Delete the EnableClientScript property in the markup code.

D.   Set EnableScript property to false.

85: Which of the following is the method name to make upper case to string value?

A.   ToUpper()

B.   ToUpperString()

C.   toUpperCase()

D.   ToUpperCase()

E.   Toupper()

86: What is the svc extension used for?

A.   ASP.NET Service File

B.   ASPX service file

C.   Windows Communication Foundation service file

D.   AJAX service file

87: Which class does the ASP.NET web form class inherit from by default?

A.   System.Web.Form

B.   System.Web. UI.Form

C.   System. Web. GUI.Page

D.   System.Web. UI.Page

88: How does a programmer secure a whole ASP.NET MVC4 website?

A.   Using System.Web.Mvc.AuthorizeAttribute() in each method

B.   Using System.Web.Mvc.AuthorizeAttribute() in each controller

C.   Registering System.Web.Mvc.AuthorizeAttribute() in RegisterGlobalFilters

89: Which Style property of the GridView Control is used for formatting Gridview Pages?

A.   HeaderStyle

B.   PagerStyle

C.   FooterStyle

90: Which method is used to kill explicitly a user's session?

A.   Session.Flush() method

B.   Session.Kill(true) method

C.   Session.Kill() method

D.   Session.Abandon() method

91: Which type is used to manage server-side state?

A.   Session level

B.   Database level

C.   All these

D.   Application level

92: Which of the following is the property to get a client side id for a control at run time?

A.   ClientID

B.   ClientSideID

C.   ID

D.   Name

93: Which of the following is the default scripting language in ASP.NET?

A.   VBScript

B.   PERL

C.   JavaScript

94: Which of the following is used to sign out from forms authentication?

A.   FormsAuthentication.Signout()

B.   FormsAuthentication.Login()

C.   UserAuthentication.Signout()

D.   UserAuthentication.Logout()

E.   FormsAuthentication.Logout()

95: Which base class do all Web Forms inherit from?

A.   System.Web.Page

B.   System.Web.UI.Page

C.   System.Web.UI

A.   30 minutes

B.   20 minutes

C.   40 minutes

D.   60 minutes

97: Which threading model is used in ASP.NET?

A.   MTA

B.   STA

C.   Not supported

D.   Single Threaded

98: Which of the following is the role of the Web API Media Type Formatter?

A.   Reads from the URI path and querystring

B.   A custom parameter binding that can read any part of the HTTP request

C.   Reads the message body only

D.   Reads the message body and serializes the response

99: In ASP.NET, what is the separation of presentation and content?

A.   MVVM

B.   Page Class Inheritance

C.   Model View Controller

D.   Code Behind

E.   Class Responsibility Collaboration

100: Which of the following SessionState Modes causes the Session_End event to fire?

A.   None

B.   SQL Server

C.   Inproc

D.   StateServer