Showing posts with label ASP. Show all posts
Showing posts with label ASP. Show all posts

ASP Interview Materials:

The Control class belongs to which namespace?
1. System.Web.UI
2. System.Web.UI.WebControls
3. System.Web
4. System
Correct Answer: -> 1
Feedback: -> That’s correct. The Control class is the base class for all the server controls that are used for building the user interface. It resides in the System.Web.UI namespace, which contains the base classes used to build the user interface of an ASP.NET page.

Which of the following state management options can be used to automatically save the value of each control before rendering the page?
1. The ViewState property
2. Hidden fields
3. Cookies
4. Query strings
Your Answer: -> 1
Feedback: -> That’s correct. Each Web Form page and the controls on the page have the ViewState property that is inherited from the base Control class. The ASP.NET framework uses the ViewState property to automatically save control-specific and page-specific values.

Which class supports page-level tracing in an ASP.NET application?
1. TraceContext
2. Trace
3. HttpHandlerConfigHandler
4. HttpModulesConfigHandler
Your Answer: -> 1
Feedback: -> That’s correct. The TraceContext class supports the trace functionality for ASP.NET pages.

Which attribute of the forms element is used in the Web.Config file to specify the page to which a user request is to be redirected for logon?
1. name
2. loginUrl
3. protection
4. timeout
Correct Answer: -> 2
Feedback: -> That’s correct. The loginUrl attribute of the forms element is used to specify the page to which the user request is to be redirected for logon when no valid authentication cookie is found.

Which of the following objects is used to store and retrieve information that can be shared among all the users of an application?
1. Request
2.. Application
3. Response
4. Server
Correct Answer: -> 2
Feedback: -> That’s correct. The Application object is used to store and retrieve the information that can be shared among all the users of an application. For example, you can use an Application object to create a chat page.

Which of the following attributes of the trace element is used to specify whether or not trace information will be displayed for each Web Form?
1. enabled
2. requestLimit
3. pageOutput
4. traceMode
Correct Answer: -> 3
Feedback: -> That’s incorrect. The enabled attribute is used to enable the trace feature for an ASP.NET application.

Which of the following is the correct definition of impersonation?
1. Impersonation refers to the process of verifying whether a user has permissions to access an application.
2. Impersonation refers to the process of restricting the access of an authenticated user to parts of the application or Web site for which a user is already authenticated.
3. Impersonation refers to an ASP.NET application using the identity of a client.
4. Impersonation refers to the practice of providing content and other facilities, such as the background color of the Web Form, to users based on their preferences.
Correct Answer: -> 3
Feedback: -> That’s incorrect. Authentication refers to the process of verifying whether a user has permissions to access an application.

Which of the following templates refers to the collection of elements and controls that are rendered once for each row in a data source?
1. SelectedItemTemplate
2. ItemTemplate
3. EditItemTemplate
4. AlternatingItemTemplate
Correct Answer: -> 2
Feedback: -> That’s incorrect. SelectedItemTemplate refers to the collection of elements and controls that are rendered when an item is selected in the server control.

Which of the following elements in the Web.Config file allows you to specify the custom settings for a Web application?
1. configSections
2. appSettings
3. customErrors
4. trace
Correct Answer: -> 2
Feedback: -> That’s correct. The appSettings element of the Web.config file is used to define the custom settings for a Web application. For example, you can use the appSettings element to store the connection string in the database that you need to access in the various Web Forms of a Web application.

Which of the following statements about a cookie is true?
1. A cookie is a server-side state management option.
2. A cookie is stored on a Web server.
3. A cookie can be either temporary or persistent.
4. A cookie contains application-specific information.
Correct Answer: -> 3
Feedback: -> That’s correct. A cookie can be either temporary or persistent. A temporary cookie, also known as a session cookie, exists in the memory space of a browser. When the browser is closed, all the session cookies added to the browser are lost. A persistent cookie is saved as a text file in the file system of the client computer.

Which of the following types of deployment projects will you use to deploy an ASP.NET application?
1. A setup project
2. A Web setup project
3. A merge module project.
4. A cab project
Correct Answer: -> 2
Feedback: -> That’s correct. A Web setup project is used to package a Web-based application and create a Windows Installer (.msi) file.

The armed forces of a small nation want to develop an Intranet site to manage the stock of arsenal in their stores as well as at forward positions. The armed forces are concerned about espionage and sabotage. Therefore, security is a very important aspect of the application. In the given scenario, which authentication scheme will be the most appropriate?
1. Basic authentication
2. Integrated Windows authentication
3. Anonymous authentication
4. Passport authentication
Correct Answer: -> 2
Feedback: -> That’s incorrect. As per the scenario, the armed forces are concerned about espionage and sabotage. However, in basic authentication, the password of a user is transmitted over a network in an unencrypted form. This makes the password vulnerable to security breaches. Therefore, basic authentication cannot be used in the given scenario.

How can you bind the value entered in the TextBox control txtCity to the Label control Label1? 1. By setting the DataSource property of the Label1 control to txtCity
2. By setting the DataMember property of the Label1 control to txtCity
3. By setting the Text property of the Label1 control to txtCity.Text
4. By using the DataBindings property of the Label1 control and setting the custom binding _expression to txtCity.Text
Correct Answer: -> 4
Feedback: -> That’s correct. To specify the data binding _expression for the Label1 control, you need to click the DataBindings property to open the Label1 DataBindings dialog box. Then, you need to click the Custom binding _expression radio button and specify the data binding _expression in the text box.

You have created a DataList control and added a Button control to it. You have not set the CommandName property of the Button control. Which of the following events will be generated when a user clicks the Button control?
1. EditCommand
2. UpdateCommand
3. ItemCommand
4. CancelCommand
Correct Answer: -> 3
Feedback: -> That’s correct. The ItemCommand event is generated when you click a Button control with no predefined CommandName.

Which file contains the scripts that define the start and end events of an ASP.NET application and its sessions?
1. AssemblyInfo.cs
2. Global.asax
3. Web.Config
4. WebApplication.vsdisco
Correct Answer: -> 2
Feedback: -> That’s incorrect. The Web.Config file is an XML file that contains configuration data on each unique URL resource used in an ASP.NET Web project.

You have created the errors.html file to display error messages for your ASP.NET application. You want to redirect a client browser to the errors.html file whenever an error occurs in the ASP.NET application. How can this be achieved?
1. By setting the defaultRedirect attribute of the customErrors element to “errors.html”
2. By setting the mode attribute of the customErrors element to “errors.html”
3. By setting the defaultRedirect attribute of the appSettings element to “errors.html”
4. By setting the redirect attribute of the customErrors element to “errors.html”
Correct Answer: -> 1
Feedback: -> That’s correct. The defaultRedirect attribute of the customErrors element is used to specify the URL to which the client browser should be redirected when an error occurs.

Which of the following statements will you use in the Web.Config file to specify that an ASP.NET application should use one of the IIS authentication schemes?
1.
2.
3.
4.
Correct Answer: -> 1
Feedback: -> That’s correct. The Windows authentication mode allows you to specify that ASP.NET application should use one of the IIS authentication schemes.

Which of the following statements about the ViewState property is true?
1. The ViewState property is a server-side state management option.
2. By default, the ViewState property of both Web pages and the controls on the Web pages is disabled.
3. Each Web Form page and the controls on the page have the ViewState property that is inherited from the base Control class.
4. The ViewState property should be enabled when you have a large volume of information to maintain.
Correct Answer: -> 3
Feedback: -> That’s incorrect. The ViewState property is a client-side state management option.

Which control allows you to display banner advertisements on an ASP.NET Web Form?
1. A DataGrid control
2. A Repeater control
3. An XML Web server control
4. An AdRotator control
Correct Answer: -> 4
Feedback: -> That’s correct. An AdRotator control allows you to display banner advertisements on an ASP.NET Web Form.

Which of the following classes provides forward-only access to a stream of XML data and checks whether or not an XML document is well-formed?
1. XmlDocument
2. XmlTextReader
3. XmlTextWriter
4. XPathDocument
Correct Answer: -> 2
Feedback: -> That’s correct. The XmlTextReader class provides forward-only access to a stream of XML data and checks whether or not an XML document is well-formed.

The XML Web server control belongs to which namespace?
1. System.Xml
2. System.Xml.Xsl
3. System.Web.UI.WebControls
4. System.Web.UI
Correct Answer: -> 3
Feedback: -> That’s incorrect. The System.Xml namespace provides a rich set of classes for processing XML data.

Which event is generated when a control triggers the reloading of an ASP.NET Web page?
1. Init
2. Load
3. Control
4. Unload
Correct Answer: -> 3
Feedback: -> That’s incorrect. The Load event is generated when an ASP.NET Web page is loaded into memory.

Which of the following state management options can be used to submit information to another page by using a URL?
1. The Viewstate property
2. Hidden fields
3. Cookies
4. Query strings
Correct Answer: -> 4
Feedback: -> That’s correct. Query strings are used if you need to submit information another page by using a URL.

ASP

What is ASP (Active Server Pages)?
ASP is a server side-scripting environment for building dynamic and interactive web pages. Since the scripts run on the server side, the web server does all the processing.

What is an .ASP file?
It is a Text File that contains the combination of the following:
• Text
• HTML tags
• Script Commands

What is the difference between ASP and HTML? Or Why ASP is better than HTML?
• ASP executes code on the server side whereas the browser interprets HTML.
• ASP can use any scripting languages
• Gets feedback from the user and return information to the user
• Create pages that will be customized to display only things that will be of interest to a particular user
• Can edit contents of a web page by updating a text file or a database rather than the HTML code itself

What are the differences between ASP and ASP.NET and is ASP.NET backward compatible to ASP.
ASP page is non compiled version ie the ASP compiler (interpreter) executes each line of ASP page when the request for a particular page is made...
Where as ASP.NET page is the pre-compiled version. When we compile the ASP.NET page, the .NET compiler compiles the ASP.NET page to the UI assemply.

How can you change the primary scripting language for a page?
Specify <%@ LANGUAGE = Scripting language %>
How are scripts executed?
ASP provides scripting engines that execute the corresponding scripting languages on the server side. Scripts should be encoded within the <%…. %>Delimiters.

What are the advantages of using ASP?
• Minimizes network traffic by limiting the need for the browser and server to talk to each other
• Makes for quicker loading time since HTML pages are only downloaded
• Allows to run programs in languages that are not supported by the browser
• Can provide the client with data that does not reside on the client’s machine
• Provides improved security measures since the script cannot be viewed by the browser

What is a "Virtual Directory"?
Virtual directories are aliases for directory paths on the server. It allows moving files on the disk between different
folders, drives or even servers without changing the structure of web pages. It avoids typing an extremely long URL each time to access an ASP page.

What are the browsers that can access ASP pages?
• Internet Explorer (supports VBScript, JavaScript)
• Netscape Communicator/ Navigator (supports only JavaScript, VBScript can be also added too)

How does the server identify and execute the server-side scripts within HTML code?
• Including the RUNAT=SERVER attribute in the
tag
• Use <% … %>server script delimiter

What is the difference between Cookies collection and Form/Querystring collection?
Cookie collection does not have the Count property.
Cookies can have multiple values for the same cookie name but each value can be referred using a key whereas in a Form/Querystring cookie each value has to be referred using an index value.


What is ServerVariables collection?
The ServerVariables collection holds the entire HTTP headers and also additional items of information about the server.

What are the collections of Session Object?
• Contents collection – contains all the variables established for a session without using thetag.
• Static collection – contains all the objects created with thetag within session scope.

What are the collections of Application Object?
* Contents collection – contains all variables added via scripts in global.asa.
* Static collection – contains the names of all objects added via thetag in global.asa.

What are the attributes of the
tags? What are their functions?
The two attributes are ACTION and METHOD
The ACTION gives the name of the ASP file that should be opened next by which this file can access the information given in the form
The METHOD determines which of the two ways (POST or GET) the browser can send the information to the server.

What is ServerVariables collection?
The ServerVariables collection holds the entire HTTP headers and also additional items of information about the server.

What is Querystring collection?
This collection stores any values that are provided in the URL. This can be generated by three methods:
• By clicking on an anchor tag

• By sending a form to the Server by the GET method
• Through user-typed HTTP address

What is ClientCertificate collection?
A ClientCertificate is an encrypted number that is stored in a file on the user’s computer. This stores details of any security certificates included with the request.

What is Request Object?
Gets information from the user. It has five collections by which values can be accessed. They are: Querystring, Form, Cookies, Server Variables & ClientCertificate.

What is a FileSystemObject object?
It provides access to the physical file system of the web server. It gets and manipulates information about
all drives in a server, folders and sub-folders on a drive and files inside a folder.

What are the properties of Session Object?
• SessionID – returns the session identification number for each user.
• Timeout – sets the timeout period assigned to the Session object for any application, in minutes.
• CodePage – determines the code page that will be used to display content.
• LCID – a locale identifier, which determines time zone and language, rules for the system.

Explain the POST & GET Method or Explain the difference between them.
POST METHOD:
The POST method generates a FORM collection, which is sent as a HTTP request body. All the values typed in
the form will be stored in the FORM collection.
GET METHOD:
The GET method sends information by appending it to the URL (with a question mark) and stored as A Querystring collection. The Querystring collection is passed to the server as name/value pair.
The length of the URL should be less than 255 characters.

What are the methods by which output stream is controlled?
• Flush – sends previous buffered output to the client immediately, but continues processing the script.
• Clear – erases any already-buffered HTML.
• End – causes the server

What are the properties used to control the expiration of the page?

• Expires – specifies the number of minutes before a page cached on a browser expires.
• ExpiresAbsolute – sets the date and time at which a page cached on a browser expires.

What are the ASP Scripting Objects?
The Dictionary object, the FileSystemObject object, TextStream object.

What is the difference between server.trasfer, server.execute and Response.redirect?
Is Response.trasfer is valid in ASP.
server.execute stops the execution of the current page and transfers the control to the URL passed in as a parameter. After that page has finished execution control passes back to the original page and execution resumes at the statement after the execute method call.

server.transfer is similar to server.execute but unlike that methos the execution does not resume to the original page but end when the new page completes executing

response.redirect transfers the control to the given url but there is server round trip.
In response.redirect the new url can be seen , but in server.execute and transfer the new page url is not seen even though the control is passed to the new page.

Performance is better in server.execute and transfer nut they cannot be used with server-side include #exec directive.

What is the function of Buffer in Response Object?
Buffer controls the HTML output stream manually.
Respose.buffer=False/True
Buffer is used to send the information to the browser.

How to Retrieve a Cookie Value?
The "Request.Cookies" command is used to retrieve a cookie value. <% fname=Request.Cookies("firstname") response.write("Firstname=" & fname) %>

When does a Session Start?
A session starts when:
• A new user requests an ASP file, and the Global.asa file includes a Session_OnStart procedure
• A value is stored in a Session variable
• A user requests an ASP file, and the Global.asa file uses thetag to instantiate an object with session scope

When does a Session End?
A session ends if a user has not requested or refreshed a page in the application for a specified period. By default, this is 20 minutes.
If you want to set a timeout interval that is shorter or longer than the default, you can set the Timeout property.

What happens to ASP pages?
The browser makes a HTTP request; the server does the processing and gives a HTML response to the browser.

What are LOCAL and GLOBAL variables?
Local variables lifetime ends when the Procedure ends. Global variables lifetime begins at the start of the
script and ends at the end of the script and it can be used by any procedure within the script. Declaring a
variable by using the keyword PRIVATE makes the variable global within the script, but if declared using PUBLIC, then all scripts can refer the variable.

How to handle Error in ASP ?
Using On Error Goto.

Can two different applications use the same GLOBAL.ASA File?
No,each application can have their own Global.asa file but it can't be shared.

What is the Default ScriptTimeOut for Server Object?
The ScriptTimeout property specifies the amount of runtime in seconds for a script before it terminates. The default value is 90 seconds.

What is the difference between Server-side validation and Client-side validation?
1. Client-side is faster than server-side as the networking time from client to server is saved
2. server-side is done on the server. Then the server converts the data into an html page and sends to the browser.
3. server-side is more secure as the user cannot see the code even he does a view-source.

What is a Dictionary object?
It lets you store and retrieve information in a flexible data structure. Each value or information stored in a Dictionary is associated with a key through which the information can be retrieved.

What purpose is served by the Application.Lock method?
It locks the Application object, preventing other clients from altering any values in the Contents collection.

Which is the default Scripting Language on the client side?
JavaScript.

What is Extranet?
An area of a web site available only to a set of registered visitors.

Which is the default Scripting Language of ASP on the Server side?
VBScript.