Tuesday, June 23, 2009

Basic ASP.NET Interview Questions - Part 2

1.What attribute do you use to hide a public .NET class from COM?
Use the ComVisible attribute to select which public .NET classes and members are visible to COM. This attribute applies hierarchically for the assembly, class, and member levels.

2.Why can’t you open a new browser window using server-side code? How would you display a page in a new window with a client-side script?
Server-side code can execute tasks only on the server. To perform a task on the client’s computer, such as opening a new browser window, the code needs to run on the client.

3.How do you declare an unmanaged procedure within .NET?
Use the DllImport attribute or a Visual Basic .NET Declare statement to declare an unmanaged procedure for use with a .NET assembly. The DllImport attribute is found in the System.Runtime.InteropServices namespace.

4.Which ASP.NET authentication mode is best suited to identifying and authorizing users who belong to a corporate network?
Windows authentication is best suited to authenticating users of a corporate network because it uses the accounts and permissions that already exist for network users.

5.What is the difference between Windows and Forms authentication user lists in Web.config?
User lists for Windows authentication are included in the
element of Web.config. User lists for Forms authentications are included in the
element of Web.config or as part of an external users database or file.

6.How does the Secure Sockets Layer (SSL) provide security in a Web application?
SSL protects data exchanged between a client and a Web application by encrypting the data before it is sent across the Internet.

7.What permissions do Web applications run under by default?
By default, Web applications run as the ASPNET user, which has limited permissions equivalent to the Users group.

8.Why is the Machine.config file important to deployed Web applications?
The Machine.config file controls many aspects of how Web applications run, including how processes are recycled, what types of request queue limits are imposed, and what interval is used when checking if users are still connected.

9.How do you configure a setup project to install an application over the Web?
To configure a setup project to install an application over the Web, select the Web Bootstrapper option from the setup project’s properties. This setting allows the Windows Installer to be downloaded and installed over the Web.

10.How do you distribute shared components as part of an installation program?
Shared components should be included as a merge module within the setup project. Merge modules manage the installation of shared components so that they’re not unnecessarily overwritten and so that they can be safely removed when no longer used. Unlike regular setup projects, merge modules can’t be installed by themselves—they can be installed only as part of an application installation.

11.How does deploying to a Web farm or a Web garden affect Session state in a Web application?
Web applications that are deployed to a Web farm or a Web garden need to identify a Session state provider in their Web.config file. This is because a single client’s requests can be directed to different processes over the course of his or her session. The Session state provider allows each different process to access the client’s Session state.

12.How do unit, integration, and regression testing relate to each other?
Unit testing is the foundation that ensures that each piece of code works correctly. Integration testing extends this concept by verifying that pieces work together without errors. Regression tests are made up of the existing unit and integration tests, which are run on a regular schedule to assure that new code did not break previously working code.

13.Why is load testing likely to be more important for a Web application than for a stand-alone Windows application?
Because Web applications can be public on the Internet, they can have hundreds, thousands, or even millions of users. Load tests let you simulate the expected demand to locate resource conflicts, performance bottlenecks, and other problems that aren’t apparent in single-user tests.

14.What is the difference between the Debug and Trace classes?
Under the default environment settings, code using the Debug class is stripped out of release builds, while code using the Trace class is left in. The classes are otherwise equivalent.

15.What are the two special steps you need to take to ensure that a COM component can use a component from a .NET assembly?
To use a .NET component from a COM tool, such as VBScript, you must:
•Register the .NET assembly in the system registry using RegAsm.exe.
•Make sure that the COM component can find the .NET assembly, either by placing the .NET assembly in the global assembly cache, by placing the two components in the same folder, or by following the other assembly-probing rules.

16.When do you generally create a web user control?
You generally create a web user control when you want to create a group of controls that can be reused throughout a project to perform some logical unit of work.

17.When do you generally create a custom control ?
You generally create a custom control when you want to combine one or more existing controls into a compiled assembly that can be easily reused in many different projects.

18.How is deriving important to creating custom Web controls?
Both composite and rendered custom controls are derived from the WebControl base class. That class provides the methods that you override to create the appearance of the custom control.

19.What is the most important method to override when you’re creating a composite custom control?
You override the CreateChildControls method to add existing controls to a composite custom control.

20.How is raising a post-back event in a composite control different from raising a post-back event in a rendered control?
In a composite control, you can use one of the contained controls to raise a post-back event. In a rendered control, you must implement the IPostBackEventHandler interface and write a client-side script to raise a post-back event.

21.Write a directive to cache responses for a Web form for 30 seconds, storing different cache responses based on the value of the lstNames control.
<%@ OutputCache Duration=”30” VaryByParam=”lstNames” %>

22.A Web form uses fragment caching to store a frequently used user control. At run time, an Object not found error occurs whenever the page is refreshed. What is a likely cause of the error?
The most likely cause is that the user control is referenced in code after it has been cached. Once cached, a user control’s properties and methods are no longer available.

23.How can you detect when application data is about to be removed from the cache?
Use the onRemoveCallback delegate.

24.What is the advantage of using CSS rather than in-line styles for formatting a Web application?
Using CSS allows you to maintain formatting separately from the content of your Web forms, so changes are easier to make and consistency is easier to maintain.

25.Why would you create a style for a class rather than for an HTML element?
You create style classes when you want to apply the same formatting to different types of elements within an application. For example, you might want to create an emphasis style class that applies the same formatting to any text, control, heading, or image that you want to draw the user’s attention to.

26.How do CSS and XSL relate to each other when it comes to formatting a Web application?
CSS and XSL are complementary techniques for formatting. CSS determines the font, color, size, background, and other appearance aspects of HTML elements on a Web page. XSL is used to transform XML files into HTML output. In this way, XSL controls the position and appearance of items based on their content. Used together, XSL performs the high-level tasks of composition and layout while CSS performs the low-level tasks of applying fonts, colors, and other appearance features

27.What are the differences between HTML and XML?
1. In XML, you create your own element names to identify hierarchical nodes of data.
2.XML syntax is much stricter than HTML: elements must always have end-tags, element names are case sensitive, attribute values must always be enclosed in quotation marks, and nested elements must be terminated within their parent elements.
3.XML identifies data conceptually based on the data’s content, rather than based on the type of formatting to apply.

28.Which HTML attribute does the server control’s ToolTip property map to in the HTML rendered by ASP.NET?
The ToolTip property is rendered as the title attribute at run time.

29.What is the difference between the CurrentCulture property and the Current­UICulture property?
The CurrentCulture property affects how the .NET Framework handles dates, currencies, sorting, and formatting issues. The CurrentUICulture property determines which satellite assembly is used when loading resources.

30.How do you detect the user’s culture?
Use the Request object’s UserLanguages array. The value at element 0 corresponds to one of the culture codes used by the CultureInfo class. For example: SLang = Request.UserLanguages(0)
SLang = Request.UserLanguages(0)

31.What is a neutral culture?
Neutral cultures represent general languages without region-specific differences, such as currency. For example, the “es” culture code represents Spanish.




No comments:

Post a Comment