Monday, July 7, 2008

ASP.NET Interview Questions

ASP.NET Interview Questions
1. What is the name of the property of ASP.NET page that you can query to determine that a ASP.NET page is being requested not data being submitted to web server?
A. FirstGet
B. Initialized
C. IncludesData
D. IsPostBack

IsPostBack

2. While creating a Web site with the help of Visual Studio 2005 on a remote computer that does not have Front Page Server Extensions installed, which Web site type will you create in Visual Studio 2005?
A. Remote HTTP
B. File
C. FTP
D. Local HTTP

Hypertext Transfer Protocol (HTTP)

3. If you want to create a new Web site with the help of Visual Studio 2005 on a Web server that is hosted by your ISP (Internet Services provider) and the Web server has Front Page Server Extensions installed, what type of Web site type would you create in Visual Studio 2005?
A. Local HTTP
B. File
C. FTP
D. Remote HTTP

Hypertext Transfer Protocol (HTTP)

4. For separating server-side code from client-side code on a ASP.NET page, what programming model should you use?
A. Separation model
B. Code-Behind model
C. In-Line model
D. ClientServer model

5. Amit created a new Web site using Visual Studio 2005 in programming language C#. Later, Amit received an existing Web page from his boss, which consisted of the Contact.aspx file with the Contact.aspx.vb code-behind page. What must Amit do to use these files?
A. Amit can simply add the files Contact.aspx, Contact.aspx.vb into the existing Web site, because ASP.NET 2.0 supports Web sites that have Web pages that were programmed with different languages.
B. The Contact.aspx file will work, but Amit must rewrite the code-behind page using C#.
C. Both files Contact.aspx and Contact.aspx.vb must be rewritten in C#.
D. Amit must create a new Web site that contains these files Contact.aspx and Contact.aspx.vb. Set a Web reference to the new site.

6. If you want to make a configuration setting change in your server that will affect to all Web and Windows applications on the current machine. Where you will make the changes?
A. Global.asax
B. Web.config
C. Machine.config
D. Global.asax

7. If you want to make a configuration setting change that will affect only the current Web application. Which file will you change?
A. Web.config that is in the same folder as the Machine.config file
B. Web.config in the root of the Web application
C. Machine.config
D. Global.asax

8. For making a configuration setting change that will affect only the current Web application. Is there any tool that has a user-friendly Graphical User Interface (GUI)?
A. The Microsoft Management Utility
B. Microsoft Word
C. Visual Studio, using the Tools > Options path
D. Web Site Administration Tool


ASP.NET 2.0 Interview Questions
9. How will you identify which event in the ASP.NET Web page life cycle takes the longest time to execute?
A. Turn on ASP.NET trace and run the Web application.
B. Add a few code to each of the page life-cycle events that will print the current time.
C. In the Web.config file, add the monitorTimings attribute and set it to True.
D. In the Web site properties, turn on the performance monitor and run the Web application. After that, open performance monitor to see the timings.

11. You are interested in examining the data that is posted to the Web server. What trace result section can you use to see this information?
A. Control Tree
B. Headers Collection
C. Form Collection
D. Server Variables

12. While creating web site you need to add an HTML Web server control to the Web page, you need to drag an HTML element from the ToolBox of Visual Studio 2005 to the Web page and then which of the following tasks you will perform?
A. Right-click the HTML element and click Run=Server.
B. Double-click the HTML element to convert it to an HTML server control.
C. Right-click the HTML element and click Run As Server Control.
D. Click the HTML element and set ServerControl to true in the Properties window.

13. While testing your ASP.NET web application you noticed that while clicking on CheckBox of one of the web page it does not cause a PostBack; you required that the CheckBox should make PostBack so Web page can be update on the server-side code. How can you make the CheckBox to cause a PostBack?
A. Set the AutoPostBack property to true.
B. Add JavaScript code to call the ForcePostBack method.
C. Set the PostBackAll property of the Web page to true.
D. Add server-side code to listen for the click event from the client.

14. While writing code in Visual Studio 2005 you creates a new instance of a ASP.NET TextBox server control, what do you need to do to get the TextBox to display on the Web page?
A. Call the ShowControl method on the TextBox.
B. Set the VisibleControl to true on the TextBox.
C. Add the TextBox instance to the form1.Controls collection.
D. Execute the AddControl method on the Web page.

15. While creating your ASP.NET web based application you want to create multiple RadioButton server controls which should be mutually exclusive, what property of RadioButton server controls you must set?
A. Exclusive
B. MutuallyExclusive
C. Grouped
D. GroupName

16. While creating an ASP.NET web application with the help of Visual Studio 2005 you are creates a Web page that has several related buttons, such as fast-forward, reverse, play, stop, and pause. There should be one event handler that handles the processes of PostBack from these Button server controls. Other than the normal Submit button, what type of button can you create?
A. OneToMany
B. Command
C. Reset
D. ManyToOne


ASP.NET 2.0 Interview Questions
17. In the Design view in Visual Studio 2005 of an ASP.NET web page, what is the easiest way to create an event handler for the default event of a ASP.NET server control?
A. Open the code-behind page and write the code.
B. Right-click the control and select Create Handler.
C. Drag an event handler from the ToolBox to the desired control.
D. Double-click the control.

18. Which of the following represents the best use of the Table, TableRow, and Table-Cell controls?
A. To create and populate a Table in Design view
B. To create a customized control that needs to display data in a tabular fashion
C. To create and populate a Table with images
D. To display a tabular result set

19. For your ASP.NET web application your graphics designer created elaborate images that show the product lines of your company. Some of graphics of the product line are rectangular, circular, and others are having complex shapes. You need to use these images as a menu on your Web site. What is the best way of incorporating these images into your Web site?
A. Use ImageButton and use the x- and y-coordinates that are returned when the user clicks to figure out what product line the user clicked.
B. Use the Table, TableRow, and TableCell controls, break the image into pieces that are displayed in the cells, and use the TableCell control’s Click event to identify the product line that was clicked.
C. Use the MultiView control and break up the image into pieces that can be displayed in each View control for each product line. Use the Click event of the View to identify the product line that was clicked.
D. Use an ImageMap control and define hot spot areas for each of the product lines. Use the PostBackValue to identify the product line that was clicked.

20. You are writing ASP.NET 2.0 Web site that collects lots of data from users, and the data collection forms spreads over multiple ASP.NET Web pages. When the user reaches the last page, you need to gather all of data, validate the data, and save the data to the SQL Server database. You have noticed that it can be rather difficult to gather the data that is spread over multiple pages and you want to simplify this application. What is the easiest control to implement that can be used to collect the data on a single Web page?
A. The View control
B. The TextBox control
C. The Wizard control
D. The DataCollection control

21. In your ASP.NET 2.0 web application you want to display an image that is selected from a collection of images. What approach will you use to implementing this?
A. Use the ImageMap control and randomly select a HotSpot to show or hide.
B. Use the Image control to hold the image and a Calendar control to randomly select a date for each image to be displayed.
C. Use the AdServer control and create an XML file with configuration of the control.
D. Use an ImageButton control to predict randomness of the image to be loaded based on the clicks of the control.

22. In your ASP.NET web application you want to display a list of clients on a Web page. The client list displays 10 clients at a time, and you require the ability to edit the clients. Which Web control is the best choice for this scenario?
A. The DetailsView control
B. The Table control
C. The GridView control
D. The FormView control

23. While developing ASP.NET 2.0 web application you want to display a list of parts in a master/detail scenario where the user can select a part number using a list that takes a minimum amount of space on the Web page. When the part is selected, a DetailsView control displays all the information about the part and allows the user to edit the part. Which Web control is the best choice to display the part number list for this scenario?
A. The DropDownList control
B. The RadioButtonList control
C. The FormView control
D. The TextBox control


ASP.NET 2.0 Interview Questions
24. While developing ASP.NET 2.0 web application you have a DataSet containing a Customer DataTable and an Order DataTable. You want to easily navigate from an Order DataRow to the Customer who placed the order. What object will allow you to easily navigate from the Order to the Customer?
A. The DataColumn object
B. The DataTable object
C. The DataRow object
D. The DataRelation object

25. Which of the following is a requirement when merging modified data into a DataSet?
A. A primary key must be defined on the DataTable objects.
B. The DataSet schemas must match in order to merge.
C. The destination DataSet must be empty prior to merging.
D. A DataSet must be merged into the same DataSet that created it.

26. You are working with a DataSet and want to be able to display data, sorted different ways. How do you do so?
A. Use the Sort method on the DataTable object.
B. Use the DataSet object’s Sort method.
C. Use a DataView object for each sort.
D. Create a DataTable for each sort, using the DataTable object’s Copy method, and then Sort the result.

27. Which of the following ways can you proactively clean up a database connection’s resources?
A. Execute the DbConnection object’s Cleanup method.
B. Execute the DbConnection object’s Close method.
C. Assign Nothing (C# null) to the variable that references the DbConnection object.
D. Create a using block for the DbConnection object.

29. What event can you subscribe to if you want to display information from SQL Print statements?
A. InfoMessage
B. MessageReceived
C. PostedMessage
D. NewInfo

30. To perform asynchronous data access, what must be added to the connection string?
A. BeginExecute=true
B. MultiThreaded=true
C. MultipleActiveResultSets=true
D. Asynchronous=true

31. Which class can be used to create an XML document from scratch?
A. XmlConvert
B. XmlDocument
C. XmlNew
D. XmlSettings

32. Which class can be used to perform data type conversion between .NET data types and XML types?
A. XmlType
B. XmlCast
C. XmlConvert
D. XmlSettings


What is an interface and what is an abstract class?
In an interface, all methods must be abstract (must not be defined). In an abstract class, some methods can be defined. In an interface, no accessibility modifiers are allowed, whereas it is allowed in abstract classes.

Session state vs. View state:
In some cases, using view state is not feasible. The alternative for view state is session state. Session state is employed under the following situations:

Large amounts of data - View state tends to increase the size of both the HTML page sent to the browser and the size of form posted back. Hence session state is used.
Secure data - Though the view state data is encoded and may be encrypted, it is better and secure if no sensitive data is sent to the client. Thus, session state is a more secure option.
Problems in serializing of objects into view state - View state is efficient for a small set of data. Other types like DataSet are slower and can generate a very large view state.
Can two different programming languages be mixed in a single ASPX file?
ASP.NET’s built-in parsers are used to remove code from ASPX files and create temporary files. Each parser understands only one language. Therefore mixing of languages in a single ASPX file is not possible.

Is it possible to see the code that ASP.NET generates from an ASPX file?
By enabling debugging using a <%@ Page Debug="true" %> directive in the ASPX file or a statement in Web.config, the generated code can be viewed. The code is stored in a CS or VB file (usually in the \%SystemRoot%\Microsoft.NET\Framework\v1.0.nnnn\Temporary ASP.NET Files).

Can a custom .NET data type be used in a Web form?
This can be achieved by placing the DLL containing the custom data type in the application root's bin directory and ASP.NET will automatically load the DLL when the type is referenced.

List the event handlers that can be included in Global.asax?
Application start and end event handlers
Session start and end event handlers
Per-request event handlers
Non-deterministic event handlers
Can the view state be protected from tampering?
This can be achieved by including an @ Page directive with an EnableViewStateMac="true" attribute in each ASPX file that has to be protected. Another way is to include the statement in the Web.config file.


When during the page processing cycle is ViewState available?
The view state is available after the Init() and before the Render() methods are called during Page load.

Do Web controls support Cascading Style Sheets?
All Web controls inherit a property named CssClass from the base class System.Web.UI.WebControls.WebControl which can be used to control the properties of the web control.

What namespaces are imported by default in ASPX files?
The following namespaces are imported by default. Other namespaces must be imported manually using @ Import directives.

System
System.Collections
System.Collections.Specialized
System.Configuration
System.Text
System.Text.RegularExpressions
System.Web
System.Web.Caching
System.Web.Security
System.Web.SessionState
System.Web.UI
System.Web.UI.HtmlControls
System.Web.UI.WebControls
What classes are needed to send e-mail from an ASP.NET application?
The classes MailMessage and SmtpMail have to be used to send email from an ASP.NET application. MailMessage and SmtpMail are classes defined in the .NET Framework Class Library's System.Web.Mail namespace.

Why do some web service classes derive from System.Web.WebServices while others do not?
Those Web Service classes which employ objects like Application, Session, Context, Server, and User have to derive from System.Web.WebServices. If it does not use these objects, it is not necessary to be derived from it.

What are VSDISCO files?
VSDISCO files are DISCO files that enable dynamic discovery of Web Services. ASP.NET links the VSDISCO to a HTTP handler that scans the host directory and subdirectories for ASMX and DISCO files and returns a dynamically generated DISCO document. A client who requests a VSDISCO file gets back what appears to be a static DISCO document.

How can files be uploaded to Web pages in ASP.NET?
This can be done by using the HtmlInputFile class to declare an instance of an tag. Then, a byte[] can be declared to read in the data from the input file. This can then be sent to the server.

How do I create an ASPX page that periodically refreshes itself?
The following META tag can be used as a trigger to automatically refresh the page every n seconds:



How can the focus be set to a specific control when a Web form loads?
This can be achieved by using client-side script:

document.forms[0].TextBox1.focus ()
The above code will set the focus to a TextBox named TextBox1 when the page loads.

How does System.Web.UI.Page's IsPostBack property work?
IsPostBack checks to see whether the HTTP request is accompanied by postback data containing a __VIEWSTATE or __EVENTTARGET parameter. If there are none, then it is not a postback.

What is WSDL?
WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint. Related concrete endpoints are combined into abstract endpoints (services). (Source: www.w3.org)

What is UDDI?
UDDI stands for Universal Description, Discovery, and Integration. It is like an "Yellow Pages" for Web Services. It is maintained by Microsoft, IBM, and Ariba, and is designed to provide detailed information regarding registered Web Services for all vendors. The UDDI can be queried for specific Web Services.

Is it possible to generate the source code for an ASP.NET Web service from a WSDL?
The Wsdl.exe tool (.NET Framework SDK) can be used to generate source code for an ASP.NET web service with its WSDL link.

Example: wsdl /server http://api.google.com/GoogleSearch.wsdl.

Why do uploads fail while using an ASP.NET file upload control to upload large files?
ASP.NET limits the size of file uploads for security purposes. The default size is 4 MB. This can be changed by modifying the maxRequestLength attribute of Machine.config's element.

Describe the difference between inline and code behind.
Inline code is written along side the HTML in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

No comments: