Set - 4

Question 1 :

Describe session handling in a webfarm, how does it work and what are the limits?

Answer :

Set the sessionState mode in the web.config file to "StateServer".
StateServer mode uses an out-of-process Windows NT Server to store state information.
It solves the session state loss problem in InProc mode.
Allows a webfarm to store session on a central server.
It provides a Single point of failure at the State Server.

Follow these simple steps:
- In a web farm, make sure you have the same in all your web servers.
- Also, make sure your objects are serializable.
- For session state to be maintained across different web servers in the web farm, the Application Path of the website in the IIS Metabase should be identical in all the web servers in the web farm.


Question 2 :

What are the disadvantages of viewstate/what are the benefits?

Answer :

Answer1:
Disadvantage of viewstate is that additional data is sent to the browser. The benefits are that you do not have to manually manage refreshing the page fields after a submit, (when re-displaying the same page).

Answer2:
Automatic view-state management is a feature of server controls that enables them to repopulate their property values on a round trip (without you having to write any code). This feature does impact performance, however, since a server controls view state is passed to and from the server in a hidden form field. You should be aware of when view state helps you and when it hinders your pages performance.


Question 3 :

What tags do you need to add within the asp:datagrid tags to bind columns manually?

Answer :

Answer1:
Set AutoGenerateColumns Property to false on the datagrid tag

Answer2:
tag and either or tags (with appropriate attributes of course)


Question 4 :

What is State Management in .Net and how many ways are there to maintain a state in .Net? What is view state?

Answer :

Web pages are recreated each time the page is posted to the server. In traditional Web programming, this would ordinarily mean that all information associated with the page and the controls on the page would be lost with each round trip.
To overcome this inherent limitation of traditional Web programming, the ASP.NET page framework includes various options to help you preserve changes — that is, for managing state. The page framework includes a facility called view state that automatically preserves property values of the page and all the controls on it between round trips.
However, you will probably also have application-specific values that you want to preserve. To do so, you can use one of the state management options.
Client-Based State Management Options:
View State
Hidden Form Fields
Cookies
Query Strings
Server-Based State Management Options
Application State
Session State
Database Support


Question 5 :

What tag do you use to add a hyperlink column to the DataGrid?

Answer :

Depends on whos definition of hyperlink your using. Manually a std html anchor tag (a) will work or you can use the micro-magical tag


Question 6 :

What is the standard you use to wrap up a call to a Web service?

Answer :

Several possible answers depending on your interpretation of the quesiton, but I think you were aiming for SOAP (with the caveat that this is MS version of SOAP)


Question 7 :

What is the difference between boxing and unboxing ?

Answer :

Boxing allows us to convert value types to reference types. Basically, the runtime creates a temporary reference-type box for the object on heap.
Eg:
int i=20;
object o=i;


Question 8 :

Describe the difference between a Thread and a Process?

Answer :

Answer1:
Thread - is used to execute more than one program at a time.
process - executes single program

Answer2:
A thread is a path of execution that run on CPU, a proccess is a collection of threads that share the same virtual memory. A process have at least one thread of execution, and a thread always run in a process context.

Answer3:
The operating system creates a process for the purpose of running a program. Each process executes a single program. Processes own resources allocated by the operating system. Resources include memory, file handles, sockets, device handles, and windows. Processes do not share address spaces or file resources except through explicit methods such as inheriting file handles or shared memory segments, or mapping the same file in a shared way.
Threads allow a program to do multiple things concurrently. At least one thread exists within each process. If multiple threads can exist within a process, then they share the same memory and file resources.

Answer4:
Thread is a light weight process, which is initialized itself by a process. Light weigt processes does not loads resources required by it itself, these are loaded by its parent process which has generated it.


Question 9 :

What is a Windows Service and how does its lifecycle differ from a "standard" EXE?

Answer :

Windows Service applications are long-running applications that are ideal for use in server environments. The applications do not have a user interface or produce any visual output; it is instead used by other programs or the system to perform operations. Any user messages are typically written to the Windows Event Log. Services can be automatically started when the computer is booted. This makes services ideal for use on a server or whenever you need long-running functionality that does not interfere with other users who are working on the same computer. They do not require a logged in user in order to execute and can run under the context of any user including the system. Windows Services are controlled through the Service Control Manager where they can be stopped, paused, and started as needed.


Question 10 :

What is the difference between an EXE and a DLL?

Answer :

An EXE can run independently, whereas DLL will run within an EXE. DLL is an in-process file and EXE is an out-process file


Question 11 :

What is strong-typing versus weak-typing? Which is preferred? Why?

Answer :

Strong type is checking the types of variables as soon as possible, usually at compile time. While weak typing is delaying checking the types of the system as late as possible, usually to run-time. Which is preferred depends on what you want. For scripts & quick stuff you will usually want weak typing, because you want to write as much less code as possible. In big programs, strong typing can reduce errors at compile time.


Question 12 :

What are PDBs? Where must they be located for debugging to work?

Answer :

Answer1:
To debug precompiled components such as business objects and code-behind modules, you need to generate debug symbols. To do this, compile the components with the debug flags by using either Visual Studio .NET or a command line compiler such as Csc.exe (for Microsoft Visual C# .NET) or Vbc.exe (for Microsoft Visual Basic .NET).

Using Visual Studio .NET
1. Open the ASP.NET Web Application project in Visual Studio .NET.
2. Right-click the project in the Solution Explorer and click Properties.
3. In the Properties dialog box, click the Configuration Properties folder.
4. In the left pane, select Build.
5. Set Generate Debugging Information to true.
6. Close the Properties dialog box.
7. Right-click the project and click Build to compile the project and generate symbols (.pdb files).

Answer2:
A program database (PDB) file holds debugging and project state information that allows incremental linking of a Debug configuration of your program.
The linker creates project.PDB, which contains debug information for the project's EXE file. The project.PDB contains full debug information, including function prototypes, not just the type information found in VCx0.PDB. Both PDB files allow incremental updates.
They should be located at bin\Debug directory


Question 13 :

What is cyclomatic complexity and why is it important?

Answer :

Cyclomatic complexity is a computer science metric (measurement) developed by Thomas McCabe used to generally measure the complexity of a program. It directly measures the number of linearly independent paths through a program's source code.

The concept, although not the method, is somewhat similar to that of general text complexity measured by the Flesch-Kincaid Readability Test.

Cyclomatic complexity is computed using a graph that describes the control flow of the program. The nodes of the graph correspond to the commands of a program. A directed edge connects two nodes, if the second command might be executed immediately after the first command. By definition,

CC = E - N + P

where
CC = cyclomatic complexity
E = the number of edges of the graph
N = the number of nodes of the graph
P = the number of connected components.


Question 14 :

What is FullTrust? Do GAC ed assemblies have FullTrust?

Answer :

Your code is allowed to do anything in the framework, meaning that all (.Net) permissions are granted. The GAC has FullTrust because it is on the local HD, and that has FullTrust by default, you can change that using caspol


Question 15 :

What does this do? gacutil /l | find /i "about"

Answer :

Answer1:
This command is used to install strong typed assembly in GAC

Answer2:
gacutil.exe is used to install strong typed assembly in GAC. gacutil.exe /l is used to lists the contents of the global assembly cache. |(pipe) symbol is used to filter the output with another command. find /i "about" is to find the text "about" on gacutil output. If any lines contains the text "about" then that line will get displayed on console window.


Question 16 :

Contrast OOP and SOA. What are tenets of each

Answer :

Service Oriented Architecture. In SOA you create an abstract layer that your applications use to access various "services" and can aggregate the services. These services could be databases, web services, message queues or other sources. The Service Layer provides a way to access these services that the applications do not need to know how the access is done. For example, to get a full customer record, I might need to get data from a SGL Server database, a web service and a message queue. The Service layer hides this from the calling application. All the application knows is that it asked for a full customer record. It doesnot know what system or systems it came from or how it was retrieved.


Question 17 :

How does the XmlSerializer work? What ACL permissions does a process using it require?

Answer :

XmlSerializer requires write permission to the systems TEMP directory.


Question 18 :

Why is catch(Exception) almost always a bad idea?

Answer :

Well, if at that point you know that an error has occurred, then why not write the proper code to handle that error instead of passing a new Exception object to the catch block? Throwing your own exceptions signifies some design flaws in the project.


Question 19 :

What is the difference between Debug. Write and Trace. Write? When should each be used?

Answer :

Answer1:
The Debug. Write call wonot be compiled when the DEBUG symbol is not defined (when doing a release build). Trace. Write calls will be compiled. Debug. Write is for information you want only in debug builds, Trace. Write is for when you want it in release build as well. And in any case, you should use something like log4net because that is both faster and better

Answer2:
Debug. Write & Trace. write - both works in Debug mode, while in Release Mode,Trace.write only will work .Try changing the Active Config property of Solution in Property page nd find the difference. Debug.write is used while debugging a project and Trace.write is used in Released version of Applications.


Question 20 :

What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?

Answer :

Debug build contain debug symbols and can be debugged while release build does not contain debug symbols, does not have [Conational("DEBUG")] methods calls compiled, can not be debugged (easily, that is), less checking, etc. There should be a speed difference, because of disabling debug methods, reducing code size etc but that is not a guarantee (at least not a significant one)


Question 21 :

Contrast the use of an abstract base class against an interface?

Answer :

Answer1:
In the interface all methods must be abstract, in the abstract class some methods can be concrete. In the interface no accessibility modifiers are allowed, which is ok in abstract classes

Answer2:
Whether to Choose VB.NET/C#.
Both the languages are using same classes and namespaces. Once it compile and generates MSIL, there is no meaning of which language it was written. If you are Java/C++ programmer better to choose C# for same coding style otherwise you can choose VB.net.


Question 22 :

How would one do a deep copy in .NET?

Answer :

Answer1:
System.Array.CopyTo() - Deep copies an Array

Answer2:
How would one do a deep copy in .NET?
The First Approach.
1.Create a new instance.
2.Copy the properties from source instance to newly created instance.
[Use reflection if you want to write a common method to achive this]

The Second Approach.
1. Serialize the object and deserialize the output.
: Use binary serialization if you want private variables to be copied.
: Use xml Serialization if you dont want private variable to be copied.


Question 23 :

What is boxing?

Answer :

Boxing is an implicit conversion of a value type to the type object
int i = 123; // A value type
Object box = i // Boxing
Unboxing is an explicit conversion from the type object to a value type
int i = 123; // A value type object box = i; // Boxing
int j = (int)box; // Unboxing


Question 24 :

Is string a value type or a reference type?

Answer :

Answer1:
String is Reference Type.
Value type - bool, byte, chat, decimal, double, enum , float, int, long, sbyte, short,strut, uint, ulong, ushort
Value types are stored in the Stack
Reference type - class, delegate, interface, object, string
Reference types are stored in the Heap

Answer2:
Yes String is reference type. C# gives two types of variable reference and value type. string and object are reference type.


Question 25 :

How does the lifecycle of Windows services differ from Standard EXE?

Answer :

Windows services lifecycle is managed by "Service Control Manager" which is responsible for starting and stopping the service and the applications do not have a user interface or produce any visual output, but "Standard executable" does not require Control Manager and is directly related to the visual output


Question 26 :

What is wrong with a line like this? DateTime.Parse(myString)

Answer :

the result returned by this function is not assigned to anything, should be something like varx = DateTime.Parse(myString)


Question 27 :

NET is Compile Time OR RunTime Environment?

Answer :

.Net is framework has CLS,CTS and CLR.CTS checks declartion of types at the time when u write code and CLS defines some rules and restrictions.and CLR comile everything at runtime with following benefits: Vastly simplified development Seamless integration of code written in various languages Evidence-based security with code identity Assembly-based deployment that eliminates DLL Hell Side-by-side versioning of reusable components Code reuse through implementation inheritance Automatic object lifetime management Self describing objects


Question 28 :

Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process.

Answer :

inetinfo.exe is theMicrosoft IIS server running, handling ASP.NET requests among other things.When an ASP.NET request is received (usually a file with .aspx extension),the ISAPI filter aspnet_isapi.dll takes care of it by passing the request tothe actual worker process aspnet_wp.exe.


Question 29 :

What is the difference between Response.Write() andResponse.Output.Write()?

Answer :

The latter one allows you to write formattedoutput.


Question 30 :

What methods are fired during the page load?

Answer :

Init() - when the pageis
instantiated, Load() - when the page is loaded into server memory,PreRender()
- the brief moment before the page is displayed to the user asHTML, Unload()
- when page finishes loading.


Question 31 :

Where does the Web page belong in the .NET Framework class hierarchy?

Answer :

System.Web.UI.Page


Question 32 :

Where do you store the information about the user is locale?

Answer :

System.Web.UI.Page.Culture


Question 33 :

What is the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"?

Answer :

CodeBehind is relevant to Visual Studio.NET only.


Question 34 :

What is a bubbled event?

Answer :

When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their event handlers, allowing the main DataGrid event handler to take care of its constituents.


Question 35 :

Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler?

Answer :

It is the Attributesproperty,
the Add function inside that property. So

btnSubmit.Attributes.Add("onMouseOver","someClientCode();")
A simple"Javascript:ClientCode();" in the button control of the .aspx page will attach the handler (javascript function)to the onmouseover event.


Question 36 :

What data type does the RangeValidator control support?

Answer :

Integer,String and Date.


Question 37 :

What is .NET?

Answer :

.NET is essentially a framework for software development. It is similar in nature to any other software development framework (J2EE etc) in that it provides a set of runtime containers/capabilities, and a rich set of pre-built functionality in the form of class libraries and APIs
The .NET Framework is an environment for building, deploying, and running Web Services and other applications. It consists of three main parts: the Common Language Runtime, the Framework classes, and ASP.NET.


Question 38 :

How many languages .NET is supporting now?

Answer :

When .NET was introduced it came with several languages. VB.NET, C#, COBOL and Perl, etc. The site DotNetLanguages.Net says 44 languages are supported.


Question 39 :

How is .NET able to support multiple languages?

Answer :

A language should comply with the Common Language Runtime standard to become a .NET language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short). This is called as Managed Code. This Managed code is run in .NET environment. So after compilation to this IL the language is not a barrier. A code can call or use a function written in another language.


Question 40 :

How ASP .NET different from ASP?

Answer :

Scripting is separated from the HTML, Code is compiled as a DLL, these DLLs can be executed on the server.


Question 41 :

What is smart navigation?

Answer :

The cursor position is maintained when the page gets refreshed due to the server side validation and the page gets refreshed.


Question 42 :

What is view state?

Answer :

The web is stateless. But in ASP.NET, the state of a page is maintained in the in the page itself automatically. How? The values are encrypted and saved in hidden controls. this is done automatically by the ASP.NET. This can be switched off / on for a single control


Question 43 :

How do you validate the controls in an ASP .NET page?

Answer :

Using special validation controls that are meant for this. We have Range Validator, Email Validator.


Question 44 :

Can the validation be done in the server side? Or this can be done only in the Client side?

Answer :

Client side is done by default. Server side validation is also possible. We can switch off the client side and server side can be done.


Question 45 :

How to manage pagination in a page?

Answer :

Using pagination option in DataGrid control. We have to set the number of records for a page, then it takes care of pagination by itself.


Question 46 :

What is ADO .NET and what is difference between ADO and ADO.NET?

Answer :

ADO.NET is stateless mechanism. I can treat the ADO.Net as a separate in-memory database where in I can use relationships between the tables and select insert and updates to the database. I can update the actual database as a batch.


Question 47 :

Observations between VB.NET and VC#.NET?

Answer :

Choosing a programming language depends on your language experience and the scope of the application you are building. While small applications are often created using only one language, it is not uncommon to develop large applications using multiple languages.


Question 48 :

Advantages of migrating to VB.NET ?

Answer :

Visual Basic .NET has many new and improved language features — such as inheritance, interfaces, and overloading that make it a powerful object-oriented programming language. As a Visual Basic developer, you can now create multithreaded, scalable applications using explicit multithreading. Other new language features in Visual Basic .NET include structured exception handling, custom attributes, and common language specification (CLS) compliance.

The CLS is a set of rules that standardizes such things as data types and how objects are exposed and interoperate. Visual Basic .NET adds several features that take advantage of the CLS. Any CLS-compliant language can use the classes, objects, and components you create in Visual Basic .NET. And you, as a Visual Basic user, can access classes, components, and objects from other CLS-compliant programming languages without worrying about language-specific differences such as data types.

CLS features used by Visual Basic .NET programs include assemblies, namespaces, and attributes.

These are the new features to be stated briefly:
Inheritance
Visual Basic .NET supports inheritance by allowing you to define classes that serve as the basis for derived classes. Derived classes inherit and can extend the properties and methods of the base class. They can also override inherited methods with new implementations. All classes created with Visual Basic .NET are inheritable by default. Because the forms you design are really classes, you can use inheritance to define new forms based on existing ones.

Exception Handling
Visual Basic .NET supports structured exception handling, using an enhanced version of the Try...Catch...Finally syntax supported by other languages such as C++.

Structured exception handling combines a modern control structure (similar to Select Case or While) with exceptions, protected blocks of code, and filters. Structured exception handling makes it easy to create and maintain programs with robust, comprehensive error handlers.

Overloading
Overloading is the ability to define properties, methods, or procedures that have the same name but use different data types. Overloaded procedures allow you to provide as many implementations as necessary to handle different kinds of data, while giving the appearance of a single, versatile procedure. Overriding Properties and Methods The Overrides keyword allows derived objects to override characteristics inherited from parent objects. Overridden members have the same arguments as the members inherited from the base class, but different implementations. A member is new implementation can call the original implementation in the parent class by preceding the member name with MyBase.

Constructors and Destructors
Constructors are procedures that control initialization of new instances of a class. Conversely, destructors are methods that free system resources when a class leaves scope or is set to Nothing. Visual Basic .NET supports constructors and destructors using the Sub New and Sub Finalize procedures.

Data Types
Visual Basic .NET introduces three new data types. The Char data type is an unsigned 16-bit quantity used to store Unicode characters. It is equivalent to the .NET Framework System. Char data type. The Short data type, a signed 16-bit integer, was named Integer in earlier versions of Visual Basic. The Decimal data type is a 96-bit signed integer scaled by a variable power of 10. In earlier versions of Visual Basic, it was available only within a Variant.

Interfaces
Interfaces describe the properties and methods of classes, but unlike classes, do not provide implementations. The Interface statement allows you to declare interfaces, while the Implements statement lets you write code that puts the items described in the interface into practice.

Delegates
Delegates objects that can call the methods of objects on your behalf are sometimes described as type-safe, object-oriented function pointers. You can use delegates to let procedures specify an event handler method that runs when an event occurs. You can also use delegates with multithreaded applications. For details, see Delegates and the AddressOf Operator.

Shared Members
Shared members are properties, procedures, and fields that are shared by all instances of a class. Shared data members are useful when multiple objects need to use information that is common to all. Shared class methods can be used without first creating an object from a class.

References
References allow you to use objects defined in other assemblies. In Visual Basic .NET, references point to assemblies instead of type libraries. For details, see References and the Imports Statement. Namespaces prevent naming conflicts by organizing classes, interfaces, and methods into hierarchies.

Assemblies
Assemblies replace and extend the capabilities of type libraries by, describing all the required files for a particular component or application. An assembly can contain one or more namespaces.

Attributes
Attributes enable you to provide additional information about program elements. For example, you can use an attribute to specify which methods in a class should be exposed when the class is used as a XML Web service.

Multithreading
Visual Basic .NET allows you to write applications that can perform multiple tasks independently. A task that has the potential of holding up other tasks can execute on a separate thread, a process known as multithreading. By causing complicated tasks to run on threads that are separate from your user interface, multithreading makes your applications more responsive to user input.


Question 49 :

What is Machine.config?

Answer :

Machine configuration file: The machine.config file contains settings that apply to the entire computer. This file is located in the %runtime install path%Config directory. There is only one machine.config file on a computer. The Machine.Config file found in the "CONFIG" subfolder of your .NET Framework install directory (c:WINNTMicrosoft.NETFramework{Version Number} CONFIG on Windows 2000 installations). The machine.config, which can be found in the directory $WINDIR$Microsoft.NETFrameworkv1.0.3705CONFIG, is an XML-formatted configuration file that specifies configuration options for the machine. This file contains, among many other XML elements, a browser Caps element. Inside this element are a number of other elements that specify parse rules for the various User-Agents, and what properties each of these parsing supports.

For example, to determine what platform is used, a filter element is used that specifies how to set the platform property based on what platform name is found in the User-Agent string. Specifically, the machine.config file contains:

platform=Win95
platform=Win98
platform=WinNT
...


That is, if in the User-Agent string the string "Windows 95" or "Win95" is found, the platform property is set to Win95. There are a number of filter elements in the browserCaps element in the machine.config file that define the various properties for various User-Agent strings.

Hence, when using the Request.Browser property to determine a user browser features, the user agent string is matched up to particular properties in the machine.config file. The ability for being able to detect a user's browser's capabilities, then, is based upon the honesty in the browsers sent User-Agent string. For example, Opera can be easily configured to send a User-Agent string that makes it appear as if it IE 5.5. In this case from the Web server perspective (and, hence, from your ASP.NET Web page perspective), the user is visiting using IE 5.5, even though, in actuality, he is using Opera.


Question 50 :

What is Web.config?

Answer :

In classic ASP all Web site related information was stored in the metadata of IIS. This had the disadvantage that remote Web developers couldn't easily make Web-site configuration changes. For example, if you want to add a custom 404 error page, a setting needs to be made through the IIS admin tool, and you're Web host will likely charge you a flat fee to do this for you. With ASP.NET, however, these settings are moved into an XML-formatted text file (Web.config) that resides in the Web site's root directory. Through Web.config you can specify settings like custom 404 error pages, authentication and authorization settings for the Web sitempilation options for the ASP.NET Web pages, if tracing should be enabled, etc.
The Web.config file is an XML-formatted file. At the root level is the tag. Inside this tag you can add a number of other tags, the most common and useful one being the system.web tag, where you will specify most of the Web site configuration parameters. However, to specify application-wide settings you use the tag.

For example, if we wanted to add a database connection string parameter we could have a Web.config file like so.