ASP.NET Test Questions Set 1

1)   What is the name of the Page object’s property that determines if a Web page is being requested without data being submitted to server?

a. IsCallback
b. IsReusable
c. IsValid
d. IsPostBack
Answer  Explanation 

ANSWER: IsPostBack

Explanation:
No explanation is available for this question!


2)   ______________ is the DataType return in IsPostback property.

a. bit
b. boolean
c. int
d. object
e. string
Answer  Explanation 

ANSWER: boolean

Explanation:
No explanation is available for this question!


3)   When does Garbage collector run?

a. When application is running low of memory
b. It runs random
c. When application is running for more than 15 minutes
d. None of the above
Answer  Explanation 

ANSWER: When application is running low of memory

Explanation:
No explanation is available for this question!


4)   Which is the first event of ASP.NET page, when user requests a web page?

a. PreLoad
b. Load
c. Preinit
d. Init
Answer  Explanation 

ANSWER: Preinit

Explanation:
1) PreInit: This event is also useful when you are dynamically (from code) set values such as master page, theme or dynamically created controls for a page.
2) Init: This event fires after each control has been initialized.
3) InitComplete: This event fires all initializations of the page and its controls have been completed.
4) PreLoad: Executes before view state has been loaded for the page and its controls and before PostBack processing.
5) Load: This event checks for PostBack and then sets control properties.
6) Control (PostBack) event(s): This event fires when any events on the page or its controls that caused the PostBack to occur. For example button’s click event.
7) LoadComplete: At this point all controls are loaded.
8) PreRender: This event fires after all regular PostBack event have taken place. It is executed before saving ViewState.
9) SaveStateComplete: If anyone makes changes to the page’s controls at this point or beyond, they are ignored.
10) Render: This event generates the client-side HTML, DHTML, and script that are necessary to display a control at the browser.
11) UnLoad: This event is used for cleanup code.


5)   What happens in the Init event of a page?

a. ViewState is loaded on the page.
b. Each child control of the page is initialized to its design time values.
c. HTML is rendered.
d. None of the above.
Answer  Explanation 

ANSWER: Each child control of the page is initialized to its design time values.

Explanation:
No explanation is available for this question!


6)   Which one of the following has a parameter called as “preserveForm”?

a. Server.transfer
b. Response.redirect


Answer  Explanation 

ANSWER: Server.transfer

Explanation:
No explanation is available for this question!


7)   Which validation control in ASP.NET can be used to determine if data that is entered into a TextBox control is of type Currency?

a. ValidationSummary
b. CompareValidator
c. RequiredFieldValidator
d. None of the above.
Answer  Explanation 

ANSWER: CompareValidator

Explanation:
You can use the CompareValidator control to do a data type check. Set its operator property to DataTypeCheck and its Type property to Currency.


8)   If we want to add graphics using asp.net which of the following web control will you use?

a. Link Button
b. AdRotator
c. Grid View
d. Layout
Answer  Explanation 

ANSWER: AdRotator

Explanation:
The AdRotator web server control cycles through a series of clickable ad banner and allows some ads to be weighted more heavily.


9)   What is/are true about master page? Choose the correct option.

a. You can add more than one master page in a website.
b. Master page can be nested.
c. ContentPlaceHolder control is required on a content page.
d. Both A and B option are correct.
Answer  Explanation 

ANSWER: Both A and B option are correct.

Explanation:
No explanation is available for this question!


10)   Which of the following statements about referencing master page methods and properties is true?

a. Content pages can reference controls in the master page.
b. Content pages can reference public properties in the master page.
c. Content pages can reference public methods in the master page.
d. All of the above.
Answer  Explanation 

ANSWER: All of the above.

Explanation:
No explanation is available for this question!


11)   How many types of authentication ASP.NET supports?

a. Windows Authentication.
b. .NET Passport Authentication.
c. Forms Authentication.
d. All of the above.
Answer  Explanation 

ANSWER: All of the above.

Explanation:
Windows authentication

It is enabled by default. When Windows authentication is enabled, users are identified by their Microsoft Windows account names.

.NET Passport authentication

It is a centralized service provided by Microsoft. .NET Passport allows users to create a single sign-in name and password to access any site that is uses .NET

Passport authentication

.NET Passport does only authentication not authorization. Passport simply tells a participating site who the user is. MSN and Hotmail uses .NET Passport authentication..

Forms authentication

In this authentication users are typically identified by a cookie. When a user is authenticated, an encrypted cookie is added to the user’s browser. As the user moves from page to page, the user is identified by the cookie.


12)   Which of the following is the default authentication mode for IIS?

a. Anonymous
b. Windows
c. Basic Authentication
d. None
Answer  Explanation 

ANSWER: Anonymous

Explanation:
No explanation is available for this question!


13)   You use the ASP.NET Web Site Administration Tool to configure ASP.NET membership with forms authentication. What should you name your login form so that you do not have to modify the Web.config file?

a. Login.aspx
b. LoginPage.aspx
c. Default.aspx
d. Auth.aspx
Answer  Explanation 

ANSWER: Login.aspx

Explanation:
If no filename is specified in the Web.config file, ASP.NET redirects unauthenticated users to the Login.aspx page, regardless of whether the page exists.


14)   What are the types of cookies?

a. Session cookies
b. Persistent cookies.
c. Dummy cookies.
d. Option A and B are correct.
Answer  Explanation 

ANSWER: Option A and B are correct.

Explanation:
There are two types of cookies: session cookies and persistent cookies. A session cookie exists only in memory. If a user closes the web browser, the session cookie will be lost.

A persistent cookie, on the other hand, can remain for months or even years. When you create a persistent cookie, the cookie is stored permanently by the user’s browser on the user’s computer.


15)   Default Session data is stored in ASP.Net.

a. StateServer
b. Session Object
c. InProcess
d. all of the above
Answer  Explanation 

ANSWER: InProcess

Explanation:
No explanation is available for this question!


16)   Which session modes stores session Information in Current Application Domain?

a. InProc
b. StateServer
c. SQLServer
d. Off
Answer  Explanation 

ANSWER: InProc

Explanation:
InProc session mode stores its session data in a memory object on that application domain. This is handled by worker process in application pool. So if you restart the server you will lose the session data. In web.config file you can mention Session mode and also you have to set the Timeout.
< system.web>
< sessionState mode=”InProc” timeout=”30”>
< /system.web>


17)   Choose the correct option about the Integrated Security property of connection object.

a. If Integrated Security=false then User ID, and Password must be specified in the connection string.
b. If Integrated Security=true then current Windows account credentials are used for authentication.
c. Both A and B option are correct.
d. None of the above.
Answer  Explanation 

ANSWER: Both A and B option are correct.

Explanation:
You can provide yes, no, true, SSPI and false value to Integrated Security property according to the requirement and security of application. If Integrated Security=false then User ID, and Password must be specified in the connection string and if true then current Windows account credentials are used for authentication.

SSPI is equivalent to specifying True.


18)   In which file you should write the connection string, so you can access it in all the web page for same application?

a. In App_Data folder.
b. In Web.config file.
c. In MasterPage file.
d. None of the above.
Answer  Explanation 

ANSWER: In Web.config file.

Explanation:
Following are the steps to create the connection string in Web.config file and access it in code behind file. In connection string data source and database name you have to provide according to your sqlserver instance and their database name.

Step 1: Create the connection string in Web.config file as follows.
< connectionStrings>
< add name="con" connectionString="Data Source =ServerName; initial catalog= DataBaseName; Integrated Security=true"/>



Step 2: In code behind file write the following code.
ConfigurationManager class is available in System.Configuration namespace;

string conStr= ConfigurationManager.ConnectionStrings["con"].ConnectionString;
SqlConnection conObj = new SqlConnection(conStr);
conObj.Open();

// Write code according to the requirement.

conObj.Close();


19)   How will you specifying the Cache Location?

a. You can use browser settings to specify where a page is cached.
b. You can use the Location attribute of the < %@ OutputCache %> directive to specify where a page is cached.
c. You can use the Location attribute in QueryString to specify where a page is cached.
d. None of the above.
Answer  Explanation 

ANSWER: You can use the Location attribute of the < %@ OutputCache %> directive to specify where a page is cached.

Explanation:
By default, when you use Page Output Caching, a page is cached in three locations: web server, any proxy servers, and browser. You can write following code to cache the page on server for 50 seconds.

< %@ OutputCache Duration="50" VaryByParam="none" Location=”Server” %>


20)   Which of these data source controls do not implement Caching?

a. LinqDataSource
b. ObjectDataSource
c. SqlDataSource
d. XmlDataSource
Answer  Explanation 

ANSWER: LinqDataSource

Explanation:
No explanation is available for this question!