Page 6 - ASP.NET 2.0 Interview Questions

Q17. Whats the use of App_Code directory in ASP.NET 2.0?

A17. Just as pages can be compiled dynamically at runtime, so can arbitrary code files (for example .cs or .vb files). ASP.NET 2.0 introduces the App_Code directory, which can contain standalone files that contain code to be shared across several pages in your application. Unlike ASP.NET 1.x, which required these files to be precompiled to the Bin directory, any code files in the App_Code directory will be dynamically compiled at runtime and made available to the application. It is possible to place files of more than one language under the App_Code directory, provided they are partitioned in subdirectories (registered with a particular language in Web.config).

Q18. Can we put code created in different languages in the same App_Code directory?

A18. By default, the App_Code directory can only contain files of the same language. However, you may partition the App_Code directory into subdirectories (each containing files of the same language) in order to contain multiple languages under the

App_Code directory. To do this, you need to register each subdirectory in the Web.config file for the application.

        <add directoryName="Subdirectory"/>

Q19. Whats the difference between Bin folder and App_Code folder?

A19. The Bin directory is like the Code directory, except it can contain precompiled assemblies. This is useful when you need to use code that is possibly written by someone other than yourself, where you don't have access to the source code (VB or C# file) but you have a compiled DLL instead. Simply place the assembly in the Bin directory to make it available to your site.

By default, all assemblies in the Bin directory are automatically loaded in the app and made accessible to pages. You may need to Import specific namespaces from assemblies in the Bin directory using the @Import directive at the top of the page.  

<@ Import Namespace="MyCustomNamespace">

Q20. How to register Assemblies in GAC (Global Assembly Cache)?

A20. The .NET Framework 2.0 includes a number of assemblies that represent the various parts of the Framework. These assemblies are stored in the global assembly cache, which is a versioned repository of assemblies made available to all applications on the machine (not just a specific application, as is the case with Bin and App_Code). Several assemblies in the Framework are automatically made available to ASP.NET applications. You can register additional assemblies by registration in a Web.config file in your application.

         <add assembly="System.Data, Version=1.0.2411.0,

Note that you still need to use an @Import directive to make the namespaces in these assemblies available to individual pages.

Q21. Can we bind data to Server Controls without writing code in ASP.NET 2.0?

A21. Yes. ASP.NET 2.0 enables a declarative solution for data binding which requires no code at all for the most common data scenarios, such as:
Selecting and displaying data
Sorting, Paging and Caching Data
Updating, Inserting and Deleting Data
Filtering or Master-Details Using Parameters

ASP.NET 2.0 introduces two types of server controls that participate in this declarative data binding model. These two types of data controls handle the complexity of the stateless Web model for data scenarios, so developers don't need to understand page request lifecycle events just to perform data binding. Another benefit of this control-based model is that it can be easily extended to support additional data access storage providers.


Home Prev Next