Soudamini in .net technology 

About Me  Home   SITE MAP     SEARCH


   

Conceptual Questions

What is the .NET Framework?

The Microsoft .NET Framework is a platform for building, deploying, and running Web Services and applications. It provides a highly productive, standards-based, multi-language environment for integrating existing investments with next-generation applications and services as well as the agility to solve the challenges of deployment and operation of Internet-scale applications. The .NET Framework consists of three main parts: the common language runtime, a hierarchical set of unified class libraries, and a componentized version of Active Server Pages called ASP.NET.

Back to Top

Runtime Technical Questions

Terminology

What is the common language runtime (CLR)?

The common language runtime is the execution engine for .NET Framework applications.

It provides a number of services, including the following:

  • Code management (loading and execution)
  • Application memory isolation
  • Verification of type safety
  • Conversion of IL to native code
  • Access to metadata (enhanced type information)
  • Managing memory for managed objects
  • Enforcement of code access security
  • Exception handling, including cross-language exceptions
  • Interoperation between managed code, COM objects, and pre-existing DLLs (unmanaged code and data)
  • Automation of object layout
  • Support for developer services (profiling, debugging, and so on)

Back to Top

What is the common type system (CTS)?

The common type system is a rich type system, built into the common language runtime, that supports the types and operations found in most programming languages. The common type system supports the complete implementation of a wide range of programming languages.

Back to Top

What is the Common Language Specification (CLS)?

The Common Language Specification is a set of constructs and constraints that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The Common Language Specification is also important to application developers who are writing code that will be used by other developers. When developers design publicly accessible APIs following the rules of the CLS, those APIs are easily used from all other programming languages that target the common language runtime.

Back to Top

What is the Microsoft Intermediate Language (MSIL)?

MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.

Combined with metadata and the common type system, MSIL allows for true cross-language integration.

Prior to execution, MSIL is converted to machine code. It is not interpreted.

Back to Top

What is managed code and managed data?

Managed code is code that is written to target the services of the common language runtime (see What is the Common Language Runtime?). In order to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C#, Visual Basic .NET, and JScript .NET code is managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/CLR).

Closely related to managed code is managed data—data that is allocated and de-allocated by the common language runtime's garbage collector. C#, Visual Basic, and JScript .NET data is managed by default. C# data can, however, be marked as unmanaged through the use of special keywords. Visual Studio .NET C++ data is unmanaged by default (even when using the /CLR switch), but when using Managed Extensions for C++, a class can be marked as managed by using the __gc keyword. As the name suggests, this means that the memory for instances of the class is managed by the garbage collector. In addition, the class becomes a full participating member of the .NET Framework community, with the benefits and restrictions that brings. An example of a benefit is proper interoperability with classes written in other languages (for example, a managed C++ class can inherit from a Visual Basic class). An example of a restriction is that a managed class can only inherit from one base class.

Back to Top

Assemblies

What is an assembly?

An assembly is the primary building block of a .NET Framework application. It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files). All managed types and resources are marked either as accessible only within their implementation unit, or as accessible by code outside that unit.

Assemblies are self-describing by means of their manifest, which is an integral part of every assembly. The manifest:

  • Establishes the assembly identity (in the form of a text name), version, culture, and digital signature (if the assembly is to be shared across applications).
  • Defines what files (by name and file hash) make up the assembly implementation.
  • Specifies the types and resources that make up the assembly, including which are exported from the assembly.
  • Itemizes the compile-time dependencies on other assemblies.
  • Specifies the set of permissions required for the assembly to run properly.

This information is used at run time to resolve references, enforce version binding policy, and validate the integrity of loaded assemblies. The runtime can determine and locate the assembly for any running object, since every type is loaded in the context of an assembly. Assemblies are also the unit at which code access security permissions are applied. The identity evidence for each assembly is considered separately when determining what permissions to grant the code it contains.

The self-describing nature of assemblies also helps makes zero-impact install and XCOPY deployment feasible.

Back to Top

What are private assemblies and shared assemblies?

A private assembly is used only by a single application, and is stored in that application's install directory (or a subdirectory therein). A shared assembly is one that can be referenced by more than one application. In order to share an assembly, the assembly must be explicitly built for this purpose by giving it a cryptographically strong name (referred to as a strong name). By contrast, a private assembly name need only be unique within the application that uses it.

By making a distinction between private and shared assemblies, we introduce the notion of sharing as an explicit decision. Simply by deploying private assemblies to an application directory, you can guarantee that that application will run only with the bits it was built and deployed with. References to private assemblies will only be resolved locally to the private application directory.

There are several reasons you may elect to build and use shared assemblies, such as the ability to express version policy. The fact that shared assemblies have a cryptographically strong name means that only the author of the assembly has the key to produce a new version of that assembly. Thus, if you make a policy statement that says you want to accept a new version of an assembly, you can have some confidence that version updates will be controlled and verified by the author. Otherwise, you don't have to accept them.

For locally installed applications, a shared assembly is typically explicitly installed into the global assembly cache (a local cache of assemblies maintained by the .NET Framework). Key to the version management features of the .NET Framework is that downloaded code does not affect the execution of locally installed applications. Downloaded code is put in a special download cache and is not globally available on the machine even if some of the downloaded components are built as shared assemblies.

The classes that ship with the .NET Framework are all built as shared assemblies.

Back to Top

If I want to build a shared assembly, does that require the overhead of signing and managing key pairs?

Building a shared assembly does involve working with cryptographic keys. Only the public key is strictly needed when the assembly is being built. Compilers targeting the .NET Framework provide command line options (or use custom attributes) for supplying the public key when building the assembly. It is common to keep a copy of a common public key in a source database and point build scripts to this key. Before the assembly is shipped, the assembly must be fully signed with the corresponding private key. This is done using an SDK tool called SN.exe (Strong Name).

Strong name signing does not involve certificates like Authenticode does. There are no third party organizations involved, no fees to pay, and no certificate chains. In addition, the overhead for verifying a strong name is much less than it is for Authenticode. However, strong names do not make any statements about trusting a particular publisher. Strong names allow you to ensure that the contents of a given assembly haven't been tampered with, and that the assembly loaded on your behalf at run time comes from the same publisher as the one you developed against. But it makes no statement about whether you can trust the identity of that publisher.

Back to Top

What is the difference between a namespace and an assembly name?

A namespace is a logical naming scheme for types in which a simple type name, such as MyType, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely under the control of the developer. For example, types MyCompany.FileAccess.A and MyCompany.FileAccess.B might be logically expected to have functionality related to file access. The .NET Framework uses a hierarchical naming scheme for grouping types into logical categories of related functionality, such as the Microsoft® ASP.NET application framework, or remoting functionality. Design tools can make use of namespaces to make it easier for developers to browse and reference types in their code. The concept of a namespace is not related to that of an assembly. A single assembly may contain types whose hierarchical names have different namespace roots, and a logical namespace root may span multiple assemblies. In the .NET Framework, a namespace is a logical design-time naming convenience, whereas an assembly establishes the name scope for types at run time.

Back to Top

Application Deployment and Isolation

What options are available to deploy my .NET applications?

The .NET Framework simplifies deployment by making zero-impact install and XCOPY deployment of applications feasible. Because all requests are resolved first to the private application directory, simply copying an application's directory files to disk is all that is needed to run the application. No registration is required.

This scenario is particularly compelling for Web applications, Web Services, and self-contained desktop applications. However, there are scenarios where XCOPY is not sufficient as a distribution mechanism. An example is when the application has little private code and relies on the availability of shared assemblies, or when the application is not locally installed (but rather downloaded on demand). For these cases, the .NET Framework provides extensive code download services and integration with the Windows Installer. The code download support provided by the .NET Framework offers several advantages over current platforms, including incremental download, code access security (no more Authenticode dialogs), and application isolation (code downloaded on behalf of one application doesn't affect other applications). The Windows Installer is another powerful deployment mechanism available to .NET applications. All of the features of Windows Installer, including publishing, advertisement, and application repair will be available to .NET applications in Windows Installer 2.0.

Back to Top

I've written an assembly that I want to use in more than one application. Where do I deploy it?

Assemblies that are to be used by multiple applications (for example, shared assemblies) are deployed to the global assembly cache. In the prerelease and Beta builds, use the /i option to the GACUtil SDK tool to install an assembly into the cache:

gacutil /i myDll.dll    

Windows Installer 2.0, which ships with Windows XP and Visual Studio .NET will be able to install assemblies into the global assembly cache.

Back to Top

How can I see what assemblies are installed in the global assembly cache?

The .NET Framework ships with a Windows shell extension for viewing the assembly cache. Navigating to % windir%\assembly with the Windows Explorer activates the viewer.

Back to Top

What is an application domain?

An application domain (often AppDomain) is a virtual process that serves to isolate an application. All objects created within the same application scope (in other words, anywhere along the sequence of object activations beginning with the application entry point) are created within the same application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation.

An OS process provides isolation by having a distinct memory address space. While this is effective, it is also expensive, and does not scale to the numbers required for large web servers. The Common Language Runtime, on the other hand, enforces application isolation by managing the memory use of code running within the application domain. This ensures that it does not access memory outside the boundaries of the domain. It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).

Back to Top

Garbage Collection

What is garbage collection?

Garbage collection is a mechanism that allows the computer to detect when an object can no longer be accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a "finalizer," which is written by the user). Some garbage collectors, like the one used by .NET, compact memory and therefore decrease your program's working set.

Back to Top

How does non-deterministic garbage collection affect my code?

For most programmers, having a garbage collector (and using garbage collected objects) means that you never have to worry about deallocating memory, or reference counting objects, even if you use sophisticated data structures. It does require some changes in coding style, however, if you typically deallocate system resources (file handles, locks, and so forth) in the same block of code that releases the memory for an object. With a garbage collected object you should provide a method that releases the system resources deterministically (that is, under your program control) and let the garbage collector release the memory when it compacts the working set.

Back to Top

Can I avoid using the garbage collected heap?

All languages that target the runtime allow you to allocate class objects from the garbage-collected heap. This brings benefits in terms of fast allocation, and avoids the need for programmers to work out when they should explicitly 'free' each object.

The CLR also provides what are called ValueTypes—these are like classes, except that ValueType objects are allocated on the runtime stack (rather than the heap), and therefore reclaimed automatically when your code exits the procedure in which they are defined. This is how "structs" in C# operate.

Managed Extensions to C++ lets you choose where class objects are allocated. If declared as managed Classes, with the __gc keyword, then they are allocated from the garbage-collected heap. If they don't include the __gc keyword, they behave like regular C++ objects, allocated from the C++ heap, and freed explicitly with the "free" method.

For additional information about Garbage Collection see:

Back to Top

Remoting

How do in-process and cross-process communication work in the Common Language Runtime?

There are two aspects to in-process communication: between contexts within a single application domain, or across application domains. Between contexts in the same application domain, proxies are used as an interception mechanism. No marshaling/serialization is involved. When crossing application domains, we do marshaling/serialization using the runtime binary protocol.

Cross-process communication uses a pluggable channel and formatter protocol, each suited to a specific purpose.

  • If the developer specifies an endpoint using the tool soapsuds.exe to generate a metadata proxy, HTTP channel with SOAP formatter is the default.
  • If a developer is doing explicit remoting in the managed world, it is necessary to be explicit about what channel and formatter to use. This may be expressed administratively, through configuration files, or with API calls to load specific channels. Options are:

    HTTP channel w/ SOAP formatter (HTTP works well on the Internet, or anytime traffic must travel through firewalls)

    TCP channel w/ binary formatter (TCP is a higher performance option for local-area networks (LANs))

When making transitions between managed and unmanaged code, the COM infrastructure (specifically, DCOM) is used for remoting. In interim releases of the CLR, this applies also to serviced components (components that use COM+ services). Upon final release, it should be possible to configure any remotable component.

Distributed garbage collection of objects is managed by a system called "leased based lifetime." Each object has a lease time, and when that time expires, the object is disconnected from the remoting infrastructure of the CLR. Objects have a default renew time-the lease is renewed when a successful call is made from the client to the object. The client can also explicitly renew the lease.

Back to Top

Interoperability

Can I use COM objects from a .NET Framework program?

Yes. Any COM component you have deployed today can be used from managed code, and in common cases the adaptation is totally automatic.

Specifically, COM components are accessed from the .NET Framework by use of a runtime callable wrapper (RCW). This wrapper turns the COM interfaces exposed by the COM component into .NET Framework-compatible interfaces. For OLE automation interfaces, the RCW can be generated automatically from a type library. For non-OLE automation interfaces, a developer may write a custom RCW and manually map the types exposed by the COM interface to .NET Framework-compatible types.

Back to Top

Can .NET Framework components be used from a COM program?

Yes. Managed types you build today can be made accessible from COM, and in the common case the configuration is totally automatic. There are certain new features of the managed development environment that are not accessible from COM. For example, static methods and parameterized constructors cannot be used from COM. In general, it is a good idea to decide in advance who the intended user of a given type will be. If the type is to be used from COM, you may be restricted to using those features that are COM accessible.

Depending on the language used to write the managed type, it may or may not be visible by default.

Specifically, .NET Framework components are accessed from COM by using a COM callable wrapper (CCW). This is similar to an RCW (see previous question), but works in the opposite direction. Again, if the .NET Framework development tools cannot automatically generate the wrapper, or if the automatic behavior is not what you want, a custom CCW can be developed.

Back to Top

Can I use the Win32 API from a .NET Framework program?

Yes. Using platform invoke, .NET Framework programs can access native code libraries by means of static DLL entry points.

Here is an example of C# calling the Win32 MessageBox function:

using System; 
using System.Runtime.InteropServices; 
 
class MainApp 
{ 
    [DllImport("user32.dll", EntryPoint=  
  

  
 
    "MessageBox")] publicstatic 
    extern int MessageBox(int hWnd, String strMessage, String strCaption, uint uiType);   public 
static
    void Main() { MessageBox( 
    0, 
        "Hello, this is PInvoke in operation!", ".NET", 0 ); } } 
    < 
/FONT>
<  
  

  
 
     /FONT> 
                

        
     
                   
     

Back to Top

Security

What do I have to do to make my code work with the security system?

Usually, not a thing—most applications will run safely and will not be exploitable by malicious attacks. By simply using the standard class libraries to access resources (like files) or perform protected operations (such as a reflection on private members of a type), security will be enforced by these libraries. The one simple thing application developers may want to do is include a permission request (a form of declarative security) to limit the permissions their code may receive (to only those it requires). This also ensures that if the code is allowed to run, it will do so with all the permissions it needs.

Only developers writing new base class libraries that expose new kinds of resources need to work directly with the security system. Instead of all code being a potential security risk, code access security constrains this to a very small bit of code that explicitly overrides the security system.

Back to Top

Why does my code get a security exception when I run it from a network shared drive?

Default security policy gives only a restricted set of permissions to code that comes from the local intranet zone. This zone is defined by the Internet Explorer security settings, and should be configured to match the local network within an enterprise. Since files named by UNC or by a mapped drive (such as with the NET USE command) are being sent over this local network, they too are in the local intranet zone.

The default is set for the worst case of an unsecured intranet. If your intranet is more secure you can modify security policy (with the .NET Framework Configuration tool or the CASPol tool) to grant more permissions to the local intranet, or to portions of it (such as specific machine share names).

Back to Top

How do I make it so that code runs when the security system is stopping it?

Security exceptions occur when code attempts to perform actions for which it has not been granted permission. Permissions are granted based on what is known about code; especially its location. For example, code run from the Internet is given fewer permissions than that run from the local machine because experience has proven that it is generally less reliable. So, to allow code to run that is failing due to security exceptions, you must increase the permissions granted to it. One simple way to do so is to move the code to a more trusted location (such as the local file system). But this won't work in all cases (web applications are a good example, and intranet applications on a corporate network are another). So, instead of changing the code's location, you can also change security policy to grant more permissions to that location. This is done using either the .NET Framework Configuration tool or the code access security policy utility (caspol.exe). If you are the code's developer or publisher, you may also digitally sign it and then modify security policy to grant more permissions to code bearing that signature. When taking any of these actions, however, remember that code is given fewer permissions because it is not from an identifiably trustworthy source—before you move code to your local machine or change security policy, you should be sure that you trust the code to not perform malicious or damaging actions.

Back to Top

How do I administer security for my machine? For an enterprise?

The .NET Framework includes the .NET Framework Configuration tool, an MMC snap-in (mscorcfg.msc), to configure several aspects of the CLR including security policy. The snap-in not only supports administering security policy on the local machine, but also creates enterprise policy deployment packages compatible with System Management Server and Group Policy. A command line utility, CASPol.exe, can also be used to script policy changes on the computer. In order to run either tool, in a command prompt, change the current directory to the installation directory of the .NET Framework (located in %windir%\Microsoft.Net\Framework\v1.0.2914.16\) and type mscorcfg.msc or caspol.exe.

Back to Top

How does evidence-based security work with Windows 2000 security?

Evidence-based security (which authorizes code) works together with Windows 2000 security (which is based on log on identity). For example, to access a file, managed code must have both the code access security file permission and must also be running under a log on identity that has NTFS file access rights. The managed libraries that are included with the .NET Framework also provide classes for role-based security. These allow the application to work with Windows log on identities and user groups.

Back to Top

C# and .NET interview questions .NET

  1. How big is the datatype int in .NET? 32 bits.
  2. How big is the char? 16 bits (Unicode).
  3. How do you initiate a string without escaping each backslash? Put an @ sign in front of the double-quoted string.
  4. What are valid signatures for the Main function?
    • publicstatic void Main()
    • publicstatic int Main()
    • publicstatic void Main( string[] args )
    • publicstatic int Main(string[] args )
  5. How do you initialize a two-dimensional array that you don’t know the dimensions of?
    • int [, ] myArray; //declaration
    • myArray= new int [5, 8]; //actualinitialization
  6. What’s the access level of the visibility type internal? Current application.
  7. What’s the difference between struct and class in C#?
    • Structscannot be inherited.
    • Structsare passed by value, not by reference.
    • Structis stored on the stack, not the heap.
  8. Explain encapsulation. The implementation is hidden, the interface is exposed.
  9. What data type should you use if you want an 8-bit value that’s signed? sbyte.
  10. Speaking of Boolean data types, what’s different between C# and C/C++? There’s no conversion between 0 and false, as well as any other number and true, like in C/C++.
  11. Where are the value-type variables allocated in the computer RAM? Stack.
  12. Where do the reference-type variables go in the RAM? The references go on the stack, while the objects themselves go on the heap.
  13. What is the difference between the value-type variables and reference-type variables in terms of garbage collection? The value-type variables are not garbage-collected, they just fall off the stack when they fall out of scope, the reference-type objects are picked up by GC when their references go null.
  14. How do you convert a string into an integer in .NET? Int32.Parse(string)
  15. How do you box a primitive data type variable? Assign it to the object, pass an object.
  16. Why do you need to box a primitive variable? To pass it by reference.
  17. What’s the difference between Java and .NET garbage collectors? Sun left the implementation of a specific garbage collector up to the JRE developer, so their performance varies widely, depending on whose JRE you’re using. Microsoft standardized on their garbage collection.
  18. How do you enforce garbage collection in .NET? System.GC.Collect();
  19. Can you declare a C++ type destructor in C# like ~MyClass()? Yes, but what’s the point, since it will call Finalize(), and Finalize() has no guarantees when the memory will be cleaned up, plus, it introduces additional load on the garbage collector.
  20. What’s different about namespace declaration when comparing that to package declaration in Java? No semicolon.
  21. What’s the difference between const and readonly? You can initialize readonly variables to some runtime values. Let’s say your program uses current date and time as one of the values that won’t change. This way you declare public readonly string DateT = new DateTime().ToString().
  22. What does \a character do? On most systems, produces a rather annoying beep.
  23. Can you create enumerated data types in C#? Yes.
  24. What’s different about switch statements in C#? No fall-throughs allowed.
  25. What happens when you encounter a continue statement inside the for loop? The code for the rest of the loop is ignored, the control is transferred back to the beginning of the loop.
  26. Is goto statement supported in C#? How about Java? Gotos are supported in C#to the fullest. In Java goto is a reserved keyword that provides absolutely no functionality.
  27. What’s the implicit name of the parameter that gets passed into the class’ set method? Value, and it’s datatype depends on whatever variable we’re changing.
  28. How do you inherit from a class in C#? Place a colon and then the name of the base class. Notice that it’s double colon in C++.
  29. Does C# support multiple inheritance? No, use interfaces instead.
  30. When you inherit a protected class-level variable, who is it available to? Classes in the same namespace.
  31. Are private class-level variables inherited? Yes, but they are not accessible, so looking at it you can honestly say that they are not inherited. But they are.
  32. Describe the accessibility modifier protected internal. It’s available to derived classes and classes within the same Assembly (and naturally from the base class it’s declared in).
  33. C# provides a default constructor for me. I write a constructor that takes a string as a parameter, but want to keep the no parameter one. How many constructors should I write? Two. Once you write at least one constructor, C# cancels the freebie constructor, and now you have to write one yourself, even if there’s no implementation in it.
  34. What’s the top .NET class that everything is derived from? System.Object.
  35. How’s method overriding different from overloading? When overriding, you change the method behavior for a derived class. Overloading simply involves having a method with the same name within the class.
  36. What does the keyword virtual mean in the method definition? The method can be over-ridden.
  37. Can you declare the override method static while the original method is non-static? No, you can’t, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override.
  38. Can you override private virtual methods? No, moreover, you cannot access private methods in inherited classes, have to be protected in the base class to allow any sort of access.
  39. Can you prevent your class from being inherited and becoming a base class for some other classes? Yes, that’s what keyword sealed in the class definition is for. The developer trying to derive from your class will get a message: cannot inherit from Sealed class WhateverBaseClassName. It’s the same concept as final class in Java.
  40. Can you allow class to be inherited, but prevent the method from being over-ridden? Yes, just leave the class public and make the method sealed.
  41. What’s an abstract class? A class that cannot be instantiated. A concept in C++ known as pure virtual method. A class that must be inherited and have the methods over-ridden. Essentially, it’s a blueprint for a class without any implementation.
  42. When do you absolutely have to declare a class as abstract (as opposed to free-willed educated choice or decision based on UML diagram)? When at least one of the methods in the class is abstract. When the class itself is inherited from an abstract class, but not all base abstract methods have been over-ridden.
  43. What’s an interface class? It’s an abstract class with public abstract methods all of which must be implemented in the inherited classes.
  44. Why can’t you specify the accessibility modifier for methods inside the interface? They all must be public. Therefore, to prevent you from getting the false impression that you have any freedom of choice, you are not allowed to specify any accessibility, it’s public by default.
  45. Can you inherit multiple interfaces? Yes, why not.
  46. And if they have conflicting method names? It’s up to you to implement the method inside your own class, so implementation is left entirely up to you. This might cause a problem on a higher-level scale if similarly named methods from different interfaces expect different data, but as far as compiler cares you’re okay.
  47. What’s the difference between an interface and abstract class? 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.
  48. How can you overload a method? Different parameter data types, different number of parameters, different order of parameters.
  49. If a base class has a bunch of overloaded constructors, and an inherited class has another bunch of overloaded constructors, can you enforce a call from an inherited constructor to an arbitrary base constructor? Yes, just place a colon, and then keyword base (parameter list to invoke the appropriate constructor) in the overloaded constructor definition inside the inherited class.
  50. What’s the difference between System.String and System.StringBuilder classes? System.String is immutable, System.StringBuilder was designed with the purpose of having a mutable string where a variety of operations can be performed.
  51. Describe the role of inetinfo.exe, aspnet_isapi.dll andaspnet_wp.exe in the page loading process. 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.
  52. What’s the difference between Response.Write() andResponse.Output.Write()? The latter one allows you to write formattedoutput.
  53. What methods are fired during the page load? 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.
  54. Where does the Web page belong in the .NET Framework class hierarchy?System.Web.UI.Page
  55. Where do you store the information about the user’s locale? System.Web.UI.Page.Culture
  56. What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"? CodeBehind is relevant to Visual Studio.NET only.
  57. What’s a bubbled event? When you have a complex control, likeDataGrid, writing an event processing routine for each object (cell, button,row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of itsconstituents.
  58. Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler? It’s the Attributesproperty, the Add function inside that property. So btnSubmit.Attributes.Add("onMouseOver","someClientCode();")
  59. What data type does the RangeValidator control support? Integer,String and Date.

Some more Questions and Answers

 

Unmanaged code:

            Unmanaged code is everything you have been programming for years, before .NET Unmanaged, or "native" code, includes VB6, COM, Win32, native C++, and so forth. It is code that predated .NET and therefore, has absolutely no knowledge of .NET and cannot directly make use of any managed facilities. Unmanaged code is one which do not targets the Runtime.

Managed code:

           

Managed code is code written for the .NET runtime or CLR. More specifically, managed code is "managed" because the code is under the control of the CLR. Managed code is one which targets the Runtime.

Cookies:

            A cookie is a piece of data that is stored on the browser to identify the user.

           

Set-Cookie: WWUSERID=43491556; path=/wconnect.

            The Set-Cookie command instructs the browser to create the client side cookie

Creating a permanent Cookie:

            To create a permanent Cookie you have to specify a date in the future. The easiest way to do this is with:

            oHeader.AddCookie("wwuserid",lcID,"/wconnect","NEVER")

            "NEVER" in this case is translated automatically into a date in the far future. You can also specify a specific date instead of never, but it must be a real date and it must follow GMT naming. For example:

            Sun, 27-Dec-2009 01:01:01 GMT

Syntax:

                         o.AddCookie(tcCookie, tcValue, tcPath, tcExpire)

 

Parameters:

tcCookie:

            Name of the cookie to create

tcValue:

            The value to set it to.

tcPath:

                        The virtual path that it applies to. By default this is the Web's root path, but realistically you should scope it to the virtual directory that the request is running in. For example if you run the following url:

            /wconnect/wc.dll?wwDemo~TestPage

            where /wconnect is a virtual directory the cookie should be scoped to the /wconnect path.

tcExpire:

                        Optional - Sets an expiration for the cookie. This must be a fully qualified string:

For example: Sun, 27-Dec-2009 01:01:01 GMT

HTMl controls:

            HTML controls represent common HTML elements and are available through the HTML tab of the Visual Studio .NET toolbox.

           

            HTML controls are only of little use in ASP.NET programs because they can't be accessed from the server-side code.

ASP.NET provides two other sets of controls that are much better suited for server-side programming: HTML server controls and Web server controls.

HTMl Server Controls:

            HTML server controls are similar to HTML controls with the added feature of server-side availability. You can convert any HTML control to run as an HTML server control by adding a runat="server" attribute to its declaration. You can accomplish the same task visually by right-clicking an HTML control and selecting Run As Server Control from the shortcut menu.

Web Server controls:

           

            Web server controls provide a higher level of abstraction than HTML server controls because their "OBJECT MODELs" matches closely with the .NET Framework rather than matching with the requirements of HTML syntax.

            The Web server controls have several advanced features, including

            1.Web server controls provide a rich object model that closely matches with the rest of the .NET Framework.

            2.Some Web server controls provide richer functionality, such as the Calendar control, AdRotator control, and so on, not available with HTML controls.

            3.Web server controls have advanced features such as automatic browser detection, automatic postback, and event bubbling.

CSS Invoking in ServerControls:

           

A.      CssClass="TextBoxStyle"

CSS Invoking in HTML Controls:

  1. Class="TextBoxStyle"

Bubbled events:

           

            Some advanced Web server controls, such as Data Grid, can also contain other controls (such as a button). Data Grid controls usually display dynamically generated data, and if each row of the Data Grid contains a button, you might have a variable number of button controls. Writing an individual event handler for each button control in this case is a tedious process. To simplify event handling, controls such as Data Grid support bubbling of events. In bubbling, all events raised at the level of child control are bubbled up to the container control, where the container control can raise a generic event in response to the child events.

Code Behind vs. Inline:

Code Behind:

           

                        This coding style places all the code that is to be executed by the server into separate files for each .aspx page.  This allows web designers who specialize in the HTML development of a site, and application developers who specialize in the programming logic of the site to work together in a way that the page designer does not disturb the code in the page. 

            E.g.:

                        <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="HelloWorldWACS.WebForm1" %>

The first thing to notice is the @Page directive.  It only contains one attribute which is the Language=C#.  This allows the web server to know which compiler to invoke on the code being run within the page.

The @Page directive includes the Codebehind= attribute which indicates the class file that will contain the code that would be included within the server script tags on an inline code page.  The Inherits= attribute gives the namespace and class that contains the code for the page.  The AutoEventWireup= attribute determines if ASP.NET controls events automatically get fired back up to the server or not.

Inline:

                        Inline code that is compiled on the web server as it is needed.

            E.g.:

<%@ Page Language="C#" %>
<tab><script runat="server">

<tab><tab>// Insert page code here
<tab><tab>//

<tab></script>

There are three ways of working with .aspx pages.

1. Inline code that is compiled on the web server as it is needed.

2. Code-behind files that are compiled into a .dll file and then removed from production.
3. Code-behind files that are compiled on the web server as they are needed.

E.g.:

<%@ Page language="c#" Src="WebForm2.aspx.cs" Inherits="HelloWorldWACS.WebForm2"%>

This page still uses a code-behind file but now the file is dynamically compiled “on the fly” when the page is requested.  This @Page directive contains a Src= attribute which directs the compiler to the code file to compile.  The Inherits= attribute determines the class to use after the file is compiled.

User Input Validation:

ASP.NET provides a set of Web server controls called validation controls that provide sophisticated validation on both the client side and the server side depending on the validation settings and the browser's capabilities.

ASP.NET ensures that validations are performed on the server side even if they were already performed on the client side. This ensures that validations are not bypassed if a malicious user circumvents client-side validation. If the client-side validation fails, the server-side validation is never performed.

Using the Page.Validate() Method and Page.IsValid Property:

Each validation control maintains an IsValid property that indicates the status of the validation test. The Page control that hosts the Web controls also contains a property called IsValid that indicates the status of the validation for the whole page. When all the validation controls on the Web form set their IsValid properties to true, Page.IsValid also becomes true. If the validation fails on any of the validation controls, Page.IsValid is false.

The Page class maintains a collection of the validation controls on a Web page that can be accessed through its Validators property. The Page class also contains a Validate() method that invokes the Validate() method of all the validation controls in the page. The Page.Validate() method is used to perform validation programmatically on all the validation controls of a Web page.

Validation Web Server Controls:

            ASP.NET validation controls derive their basic functionality from the BaseValidator abstract class available in the System.Web.UI.WebControls.

ASP.NET provides the following validation controls that derive their functionality from the BaseValidator class: RequiredFieldValidator, RegularExpressionValidator, RangeValidator, CompareValidator, and CustomValidator.

These validation controls are usually associated with the input server controls on which the validation needs to be performed. For validation to work properly, the validation control and the input server control should be placed in the same container control. The validation controls are usually placed next to the associated input control so that you can display error messages or indicators next to the input control. You can associate any number of validation controls with an input server control.

3.10 Important Members of the BaseValidator Class

Member

Type

Description

ControlToValidate

Property

Specifies the ID of the input server control that needs to be validated. This property should be passed a valid ID. However, it can be empty for a custom validation control.

Display

Property

Specifies how to display the inline error message contained in the Text property. It can be any of the ValidatorDisplay enumeration values, including Dynamic (the space is dynamically added), None (the message is never displayed), and Static (the space is occupied when the validation control is rendered).

EnableClientScript

Property

Indicates whether the client-side validation is enabled. The default is true.

Enabled

Property

Indicates whether the validation control is enabled. If false, the validation is never performed.

ErrorMessage

Property

Represents the error message to be displayed by the ValidationSummary control when the validation fails. If the Text property is not set, this message is displayed inline.

ForeColor

Property

Specifies the foreground color in which the message is displayed when the validation fails. The default value is Color.Red.

IsValid

Property

Indicates whether the input control passes the validation.

Text

Property

Specifies the text of the error message displayed by the validation control inline.

Validate()

Method

Performs the validation on the associated input control and then updates the IsValid property with the result of the validation.

The RequiredFieldValidator Control:

The RequiredFieldValidator control can be used to check whether the input control contains an entry. It makes the associated input control a required field in the Web page and ensures that some input data is passed to it. The control also trims whitespace prior to checking for the required field entry.

The RequiredFieldValidator control contains a special property called InitialValue that can be passed the initial value of the associated input control. During validation, if the input control's validation property contains the same initial value or is empty, it sets IsValid to false, indicating that the validation failed.

CAUTION

The RequiredFieldValidator control is the only validation control that ensures that the associated input control is a required field. Other validation controls assume the input control's data to be valid if it is left blank.

The RegularExpressionValidator Control:

The RegularExpressionValidator control checks whether the associated input control's validation property matches a Specified pattern. This pattern is specified by the ValidationExpression property using a regular expression. If you are not familiar with regular expressions, you can find more information in the Microsoft .NET Framework documentation.

The RangeValidator Control:

The RangeValidator control is used to check whether the input control contains a value in the Specified range. You can check the range of values against different data types such as String, Date, and Integer.

Table 3.11 shows the important properties of the RangeValidator class.

Table 3.11 Important Properties of the RangeValidator Class

Property

Description

MaximumValue

Specifies the upper value of the validation range.

MinimumValue

Specifies the lower value of the validation range.

Type

Specifies the data type to be used when comparing the data.

The CompareValidator Control:

The CompareValidator control is used to compare the input server control's value against another value. The CompareValidator control can compare against a value specified to the validator control or against the value of another input control. The comparison can be made with different comparison operators such as equal, greater than, and so on. A special comparison operation can be used to verify that the associated input control's value is in the specified data type. You can make comparisons against various data types, such as String, Date, Integer, and so on.

Table 3.12 shows the important properties of the CompareValidator class.

Table 3.12 Important Properties of the CompareValidator Class

Property

Description

ControlToCompare

-Specifies the input server control against whose value the associated input control is to be validated.

Operator

Specifies the comparison operation to be performed.

Type

Specifies the data type to be used when comparing the data.

ValueToCompare

-Specifies the value against which the associated input control is to be validated.

CAUTION

If both the ControlToCompare and ValueToCompare properties are set for a CompareValidator control, the ControlToCompare property takes precedence.

TIP

If the Operator property of a CompareValidator is set to DataTypeCheck, the ControlToCompare and ValueToCompare properties are ignored. The validator control tries to convert the input control value to the data type specified by the Type property and sets the IsValid property with the result.

The CustomValidator Control:

The CustomValidator control allows you to build a validation control for a custom specification. You can perform any custom validation both at the server side and at the client side with the help of this validation control.

This control exposes a property called ClientValidationFunction that specifies the name of the client script function to be executed for validation on the client side. This custom validation function is passed two arguments: The first one is the custom validator control, and the second argument is an object that contains two properties—IsValid and Value. The Value property contains the value that is to be validated, and the IsValid property is used to set the result of the validation.

At the server side, during the validation on the server, the validation control fires a ServerValidate event. An event handler containing the custom validation code is added to this event to perform validation on the server. The event sends a ServerValidateEventArgs object containing event-related data. This object contains two properties: The Value property contains the value of the control that is to be validated, and the IsValid property is used to set the result of the validation.

The ValidationSummary Control

The ValidationSummary control is used to display a summary of all the validation errors of a Web page. It displays the ErrorMessage property of the validation controls in the summary. If the ErrorMessage property is not set, the Text property is displayed as error messages for all the validation controls whose validations fail.

Table 3.13 shows the important properties of the ValidationSummary class.

Table 3.13 Important Properties of the ValidationSummary Class

Property

Description

DisplayMode

Specifies the way in which the validation summary is displayed. Values are defined by the ValidationSummaryDisplayMode enumeration and include BulletList (default), List, and SingleParagraph.

EnableClientScript

Indicates whether the validation summary control should generate client-side script to update itself. The default is true.

ForeColor

Specifies the foreground color in which the error messages are displayed when the validation fails. The default value is Color.Red.

HeaderText

Specifies the header text of the validation summary control.

ShowMessageBox

Indicates whether the validation summary messages should be displayed in a message box. The default is false.

ShowSummary

Indicates whether the validation summary messages should be displayed inline in the validation summary control. The default is true.

Server-Side Vs Client-Side Coding:

            The advantages of Server-Side scripting are many. Because all of the server side code is executed before the HTML is sent to the browser, your code is hidden. Server-side code is also the only choice if you want to access files and directories on the local machine. Server-side code is also browser independent. Because the HTML code returned by the server is simple HTML, you do not have to worry about the version of browser the client is using. The disadvantage to server-side scripting is that the server must use valuable resources to parse each page it sends out. This could slow down your web site.

Client-side scripting can be very useful. The major advantage is that each web browser uses its own resources to execute the code found on the web page. This eases the burden on the server. The disadvantages are that you can not prevent the user from seeing your code and that you can not use client-side code to access local files, directories, or databases.

Enable-View State Property:

            Sets or retrieves a value indicating whether the server control persists its view state to the requesting client.

Inline

<asp: control EnableViewState = true | false ... >

Script

Control.EnableViewState [ = true | false ]

You must enable view state for the server control to maintain its state across HTTP requests. A server control's view state, and the view state of any child controls it contains, is the accumulation of all its property values. In order to preserve these values across HTTP requests.

Server.Transfer vs. Response.Redirect:

            Redirect and Transfer both cause a new page to be processed, but the interaction between the client (web browser) and server (ASP.NET) is different in each situation.

Redirect: A redirect is just a suggestion – it’s like saying to the client “Hey, you might want to look at this”. All you tell the client is the new URL to look at, and if they comply, they do a second request for the new URL.

If you want to pass state from the source page to the new page, you have to pass it either on the URL (such as a database key, or message string), or you can store it in the Session object (caveat: there may be more than one browser window, and they’ll all use the same session object).

e.g. Redirect to the new.aspx page, passing an ID on the query string. "true" stops processing the current page:

Response.Redirect("new.aspx?id=34", true);

Transfer: A transfer happens without the client knowing – it’s the equivalent of a client requesting one page, but being given another. As far as the client knows, they are still visiting the original URL.
          Sharing state between pages is much easier using Server.Transfer – you can put values into the Context.Items dictionary, which is similar to Session and Application, except that it lasts only for the current request. (search for HttpContext in MSDN). The page receiving postback can process data, store values in the Context, and then transfer to a page that uses the values.

e.g. Store a message in the context dictionary, and transfer to the default.aspx page (which can then display the message):

Context.Items["Message"] = "Your password was changed successfully";

Server.Transfer("default.aspx");

How to Choose one over another?:

  • Response.Redirect is more user-friendly, as the site visitor can bookmark the page that they are redirected to.
  • Transferred pages appear to the client as a different url than they really are. This means that things like relative links / image paths may not work if you transfer to a page from a different directory.
  • Server.Transfer has an optional parameter to pass the form data to the new page.
  • Since the release version, this no longer works, because the Viewstate now has more security by default (The EnableViewStateMac defaults to true), so the new page isn’t able to access the form data. You can still access the values of the original page in the new page, by requesting the original handler.

Why Migrate to VB.NET: (Also for .NET)

           

·        Managed Code is a very important feature of the .NET architectural framework. VB.NET code targets the Common Language Runtime (CLR) by compiling into an intermediate language, which is then executed under strict control (managed). The application also becomes more maintainable because of the managed code.

·        Under the .NET framework, VB.NET applications are packaged as self-contained, self-describing, versioned assemblies (collection of classes and meta data). One can deploy, remove and manage N different versions of an application or DLL on the same machine without creating conflicts

·        Desktop applications can be much more easily converted to Web Based applications using the WebForms paradigm of .NET made available throughVB.NET.

·        XML Web Services creation and integration as facilitated by the .NET platform are readily available through VB.NET.

·        .NET applications when developed carefully can be platform independent. Managed code built using .NET will run on platforms that host the .NET framework irrespective of the Operating System or machine type.

·        VB.NET uses XML to transfer data between the various layers in the DNA Architecture i.e. data are passed as simple text strings.

·        VB.NET is totally object oriented . This is a major addition that VB6 and other earlier releases didn't have.

·        Error handling has changed in VB.NET. A new Try-Catch-Finally block has been introduced to handle errors and exceptions as a unit, allowing appropriate action to be taken at the place the error occurred thus discouraging the use of ON ERROR GOTO statement. This again credits to the maintainability of the code.

·        Another great feature added to VB.NET is free threading against the VB single-threaded apartment feature.

·        CLR takes care of garbage collection i.e. the CLR releases resources as soon as an object is no more in use. This relieves the developer from thinking of ways to manage memory. CLR does this for them.

·        The .NET framework comes with ADO.NET , which follows the disconnected paradigm , i.e. once the required records are fetched the connection no longer exists.

Methods of Migrating:

MigrationWizard:
             Visual Studio.NET provides a Visual Basic Upgrade Wizard (also called as Migration Wizard). This wizard does almost the entire migration barring some modifications that must be made to complete the upgrade process. The wizard produces a report in HTML format with the information of the places where it failed to migrate the application to .NET.

Fresh Design:
             Redesign of certain core modules or perhaps the whole application is a possible approach if new features of the .NET architectural framework are considered. Managed code (under CLR) can run in tandem with unmanaged code (e.g. COM components). Therefore it is possible to reuse many existing components as such.

Use of Customized tools to enhance migration:
            Porting driven by a wizard and re-design are easier when migrated using customized tools like the “Cal-Migrater” developed internally by CSWL for a health care product migration. This tool makes use of both the wizard and redesign approach to make faster pace through the .NET porting activity.

Issues While Migrating:

  • Avoid using late binding. This is because properties and methods cannot be verified during the upgrade process.
  • Specify default properties. VB6 specifies a default property for every component. For example, the default of Textbox is Text property and Caption is default for Label component. But in VB.NET there is nothing called as default property.
  • Use Zero-Bound Array. In VB we can declare an array with any positive integer as its lower bound. But in VB.NET all the arrays are zero bound.
  • Examine API calls with fixed length strings in VB application because VB.NET doesn't support fixed length strings.
  • Lines and Shapes are not supported in VB.NET and hence cannot be upgraded. Instead a graphic object is provided for shapes.
  • Use constants instead of underlying values. VB6 constants will convert to the correct value when upgraded to VB.NET, but if actual values are used then it may end up with wrong hard-coded values. For example, for Boolean values using -1 and 0 instead of True and False and will have an adverse effect in VB.NET because inVB.NET True is 1

Global.asax File:

            The Global.asax file contains subroutines that handle application wide events and objects declared with application scope. If you add other modules to your standard application events, additional events are exposed in the Global.asax file.

Web.Config File:

           

            An application can contain in its root directory a Web.Config file that specifies configuration information for the entire application. Web.Config files, which are standard, human-readable XML files that you can open and modify with any text editor.

Can you give an example of what might be best suited to place in
the Application_Start and Session_Start subroutines?:

            The Application_Start event is guaranteed to occur only once throughout the lifetime of the application. It's a good place to initialize global variables.

            The ASP.NET framework uses a pool of application instances to process each request to the server. When a request is made, an application instance is assigned to the request. Immediately after any of these application instances are created, the Init event is raised.

Requesting the first page from the Web site raises both the Application_Start and Init events. The Application_Start event won't be raised again for the lifetime of the application. The Init event, on the other hand, might be raised multiple times.

You can use the Init event to initialize any variables or objects that you'll need to use throughout the lifetime of a particular application instance. If you assign values to local variables, the variables retain their values across multiple requests.

What is ASP.NET Web Forms?

The ASP.NET Web Forms page framework is a scalable common language runtime programming model that can be used on the server to dynamically generate Web pages.  Web Forms enable developers to easily create cross-platform, cross-browser programmable Web applications, using the same techniques employed to build "forms-based" desktop applications. Supported in Visual Studio with powerful rapid application development (RAD) tools for designing and programming your forms.

Assemblies:

            Assemblies are building blocks of programming in the .Net Framework. An Assembly contains the MSIL code, which the CLR executes, and type Meta Data. An  Assembly also contains the Assembly manifest which contains information about the assembly version, its security identity, the resources required by the assembly, and the scope of the assembly.

 

What’s a delegate?:

            A delegate is nothing but a object which encapsulates a reference to a method. In C++ they were referred to as function pointers.

What’s a satellite assembly? :

When you write a multilingual or multi-cultural application in .NET, and want to distribute the core application separately from the localized modules, the localized assemblies that modify the core application are called satellite assemblies.

What debugging tools come with the .NET SDK?:

CorDBG – command-line debugger, and DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR. To use CorDbg, you must compile the original C# file using the /debug switch.

Definitions of Errors and Exceptions:

            An Error is an Event which happens during the exceptions of the code and disrupts the flow of the program and creates the exceptions object.

          When an error interrupts the flow, the program tries to find an exception handler — a block of code that tells it how to react — that will help it resume the flow.                           

 In other words, an error is the event; an exception is the object that the event creates.

OOPS Concepts in VB.NET:

If you do not put the Overrides keyword on the function in the derived class, the function is assumed to shadow the original function. A shadowed function is a function in the derived class that has the same name as a function in the base class but is not intended to override the base class function.

Tip:   To minimize complexity and simplify maintenance, limit your inheritance hierarchies to no more than about four levels.

You should not use inheritance when:

  • You only need one function from the base class. If this is the case, you should delegate to the class instead of inheriting from it.
  • If you would need to override all of the functions. If this is the case, you should use an interface instead of implementation inheritance.
  • The semantics of the hierarchy are not clear. If there is no clear "is a" type of relationship, such as an educational customer "is a" customer, then delegation or an interface may be a better solution. For example, a vendor has a name like a customer. So the Vendor class could inherit from the Customer class to get the name. However, it is not accurate to say that a vendor "is a" customer. So the semantics are not clear and inheritance should not be used in this case.

Building Constructors and Destructors:

           

            Visual Basic .NET introduces true constructors that are executed whenever a new instance of the class is created. These constructors are defined with a subroutine named New.

            You can pass data to a constructor for more flexibility and power in initializing the object. Constructors with parameters are called  parameterized constructors.

           

Both of these constructors can be define for one class. Actually, any number of constructors can be defined for a class as long as they each have different parameters. This feature is called overloading. The appropriate constructor is called based on the data passed to the constructor. You do not have to define a constructor. If you don't create one, a default constructor is used.

           

Instead of a Terminate event, Visual Basic .NET provides a Finalize destructor. This destructor is called when the .NET garbage collector determines that the object is not longer needed. There may be a delay between the time an object is terminated and the time the garbage collector actually destroys the object.

Tip:  You should not normally use a Finalize destructor because of this delay and the additional processing required by the system to manage objects with a Finalize destructor. Use the Dispose destructor instead. In order to better manage the resources used by your class, implement the IDisposable interface and the Dispose destructor.

The Inherits keyword defines the parent or base class. All of the public properties and methods of the base class are accessible to this derived class.

The Overrides keyword on the second function denotes that this is overriding the function defined within the base class. This allows a derived class to provide its own implementation of a particular function.

Inherited Event Handlers in Components:

Overriding an inherited event handler is the same as overriding any other kind of inherited method, with one important difference: When you override an inherited event handler, you have to remove the Handles clause.

Protected Overrides Sub Button1_Click(ByVal sender As System.Object, _

   ByVal e as System.EventArgs)

   Static Counter as Integer = 0

   Counter += 1

   MessageBox.Show (" This inherited button has been clicked " & _

      Counter.ToString() & " times.")

End Sub

Diffgrams:

            A DataSet uses a DiffGram to store and preserve all versions of data that it contains. A DiffGram is in XML forma. We can use Diffgrams to differentiate between the current and original versions of data. When we create a DataSet with DiffGram, it is populated with all the information that we require to recreate the contents of the DataSet.

What is Boxing and UnBoxing in C# :

            Boxing and Unboxing is a  essential concept in C#’s type system. With Boxing and Unboxing one can link between value-types and reference-types by allowing any value of a value-type to be converted to and from type object. Boxing and Unboxing enables a unified view of the type system wherein a value of any type can ultimately be treated as an object.

Converting a value type to reference type is called Boxing. Unboxing is an explicit operation.

The example

class Test
{
  static void
Main
()
  {
   int i = 1;
   object o = i;    // boxing
   int j = (int) o; // unboxing
  }
}

An int value can be converted to object and back again to int. This example shows both Boxing and Unboxing. We can only UnBox a variable that has been previously Boxed.

URI:    UNIFORM RESOURCE IDENTIFIER

            URIs are simple text strings that refer to Internet resources. URIs may refer to documents, resources, to people, and indirectly to anything.

URL     A URL is a Uniform Resource Locator. Think of it as a networked extension of the standard filename concept: not only can you point to a file in a directory, but that file and that directory can exist on any machine on the network, can be served via any of several different methods, and might not even be something as simple as a file: URLs can also point to queries, documents stored deep within databases, the results of a finger or archie command, or whatever.

Types:

·        File URL

               file://ftp.yoyodyne.com/pub/files/foobar.txt

·        Gopher URL à

               gopher://gopher.yoyodyne.com/

·        HTTP URL

    

        http://www.yoyodyne.com/pub/files/foobar.html

·        Partial or Relative URL

    

     anotherfile.html”

    

IHTTP Module:

            Provides module initialization and disposal events to the inheriting class.

           

Methods:

                       

Method

Description

Dispose

Disposes of the resources (other than memory) used by the module that implements IHttpModule.

Init

Initializes a module and prepares it to handle requests.

WEB SERVICES:

            Services and components that can be used on the Internet. Web services provide new added value services by combining various Web services without the need for manual input. Web services use XML-related technologies such as SOAP as the communication protocol, WSDL as the interface description language, and UDDI for registering and searching services. Sometimes called XML Web services.

            Web Services represent black-box functionality that can be used and reused without regard to how the service is implemented.

The common language runtime provides built-in support for creating and exposing Web Services. The resulting model is both scalable and extensible, and embraces open Internet standards (HTTP, XML, SOAP, WSDL) so that it can be accessed and consumed from any client or Internet-enabled device.

ASP.NET provides support for Web Services with the .asmx file. An .asmx file is a text file that is similar to an .aspx file. These files can be part of an ASP.NET application that includes .aspx files. These files are then URI-addressable, just as .aspx files are.

The following example shows a very simple .asmx file.

<%@ WebService Language="C#" Class="HelloWorld" %>

using System;

using System.Web.Services;

public class HelloWorld : WebService {

     [WebMethod] public String SayHelloWorld() {

          return "Hello World";

     }

}

<%@ WebService Language="VB" Class="HelloWorld" %>

Imports System

Imports System.Web.Services

Public Class HelloWorld :Inherits WebService

     <WebMethod()> Public Function SayHelloWorld() As String

          Return("Hello World")

     End Function

End Class

<%@ WebService Language="JScript" Class="HelloWorld" %>

import System;

import System.Web.Services;

public class HelloWorld extends WebService {

     WebMethodAttribute public function SayHelloWorld() : String {

          return "Hello World";

     }

}

To make this service available,   We might name the file HelloWorld.asmx and place it on a server called GotDotNet.com inside a virtual directory called someFolder. Using a Web browser, you could then enter the URL http://apps.gotdotnet.com/QuickStart/HelloWorld/HelloWorld.asmx, and the resulting page would show the public methods for this Web Service (those marked with the WebMethod attribute), as well as which protocols (such as SOAP, or HTTP GET) you can use to invoke these methods.

Entering the address:                                          http://apps.gotdotnet.com/QuickStart/HelloWorld/HelloWorld.asmx?WSDL into the browser returns a Web Service Description Language (WSDL) document. This WSDL document is very important, and is used by clients that will access the service.

Accessing Web Services:

In addition to the ASP.NET server side technology that allows developers to create Web Services, the .NET Framework provides a sophisticated set of tools and code to consume Web Services. Because Web Services are based on open protocols such as the Simple Object Access Protocol (SOAP), this client technology can also be used to consume non-ASP.NET Web Services.

Within the SDK, there is a tool called the Web Services Description Language tool (WSDL.exe). This command-line tool is used to create proxy classes from WSDL. For example, you could enter:

WSDL http://apps.gotdotnet.com/QuickStart/HelloWorld/HelloWorld.asmx?WSDL

to create a proxy class called HelloWorld.cs.

This class would look very similar to the class created in the previous section. It would contain a method called SayHelloWorld that returns a string. Compiling this proxy class into an application and then calling this proxy class's method results in the proxy class packaging a SOAP request across HTTP and receiving the SOAP-encoded response, which is then marshaled as a string.

WSDL.exe accepts a variety of command-line options, however to create a proxy only one option is required: the URI to the WSDL. In this example, we are passing a few extra options that specify the preferred language, namespace, and output location for the proxy. We are also compiling against a previously saved WSDL file instead of the URI to the service itself:

wsdl.exe /l:CS /n:MathService /out:MathService.cs MathService.wsdl

Once the proxy class exists, you can create objects based on it. Each method call made with the object then goes out to the URI of the XML Web service (usually as a SOAP request).

Repeater Control:

           

            The Repeater control is used to display a repeated list of items that are bound to the control. The Repeater control may be bound to a database table, an XML file, or another list of items.

Templates:

          1. Header template

            2. Item template

          3. footer template

            4. Alternating Item template

            5. Separator template

<%@ Import Namespace="System.Data" %>

<script runat="server">

sub Page_Load

if Not Page.IsPostBack then

  dim mycdcatalog=New DataSet

  mycdcatalog.ReadXml(MapPath("cdcatalog.xml"))

  cdcatalog.DataSource=mycdcatalog

  cdcatalog.DataBind()

end if

end sub

</script>

<html>

<body>

<form runat="server">

<asp:Repeater id="cdcatalog" runat="server">

<HeaderTemplate>

<table border="0" width="100%">

<tr>

<th>Title</th>

<th>Artist</th>

<th>Country</th>

<th>Company</th>

<th>Price</th>

<th>Year</th>

</tr>

</HeaderTemplate>

<ItemTemplate>

<tr>

<td><%#Container.DataItem("title")%></td>

<td><%#Container.DataItem("artist")%></td>

<td><%#Container.DataItem("country")%></td>

<td><%#Container.DataItem("company")%></td>

<td><%#Container.DataItem("price")%></td>

<td><%#Container.DataItem("year")%></td>

</tr>

</ItemTemplate>

<SeparatorTemplate>

<tr>

<td colspan="6"><hr /></td>

</tr>

</SeparatorTemplate>

<FooterTemplate>

</table>

</FooterTemplate>

</asp:Repeater>

</form>

</html>

</body>

Also we can have the alternating item template as

<AlternatingItemTemplate>

<tr bgcolor="#e8e8e8">
<td><%#Container.DataItem("title")%></td>

<td><%#Container.DataItem("artist")%></td>

<td><%#Container.DataItem("country")%></td>

<td><%#Container.DataItem("company")%></td>

<td><%#Container.DataItem("price")%></td>

<td><%#Container.DataItem("year")%></td>

</tr>

</AlternatingItemTemplate>

<FooterTemplate>

ArrayList:

       

      The ArrayList object is a collection of items containing a single data value.

Items are added to the ArrayList with the Add() method.

<script runat=”server”>

Sub Page_Load

if Not Page.IsPostBack then

  dim mycountries=New ArrayList

  mycountries.Add("Norway")

  mycountries.Add("Sweden")

  mycountries.Add("France")

  mycountries.Add("Italy")

  mycountries.TrimToSize()

  mycountries.Sort()

  mycountries.Reverse()

end if

end sub

</script>

        By default, an ArrayList object contains 16 entries. An ArrayList can be sized to its final size with the TrimToSize() method.

               An ArrayList can also be sorted alphabetically or numerically with the Sort() method.

            To sort in reverse order, apply the Reverse() method after the Sort() method

To bind data to a RadioButtonList control, first create a RadioButtonList control (without any asp:ListItem elements) in an .aspx page:

<html>

<body>

<form runat="server">

<asp:RadioButtonList id="rb" runat="server" />

</form>

</body>

</html>

Then add the script that builds the list and binds the values in the list to the RadioButtonList control.

Datasource Vs. DataBind:

           

            The DataSource property of the List control is set to the ArrayList and it defines the data source of the List control. The DataBind() method of the List control binds the data source with the List control

`

HashTable:

           

            The Hashtable object contains items in key/value pairs. The keys are used as indexes, and very quick searches can be made for values by searching through their keys.

Items are added to the Hashtable with the Add() method.

The following code creates a Hashtable named mycountries and four elements are added:

<html>

<script runat="server">

sub Page_Load

if Not Page.IsPostBack then

  dim mycountries=New Hashtable

  mycountries.Add("N","Norway")

  mycountries.Add("S","Sweden")

  mycountries.Add("F","France")

  mycountries.Add("I","Italy")

  rb.DataSource=mycountries
  rb.DataValueField="Key"
  rb.DataTextField="Value"
  rb.DataBind()

end if

end sub

</script>

<body>

<form runat="server">

<asp:RadioButtonList id="rb" runat="server"

AutoPostBack="True" onSelectedIndexChanged="displayMessage" />

<p><asp:label id="lbl1" runat="server" /></p>

</form>

</body>

</html>

The SortedList Object:

The SortedList object contains items in key/value pairs. A SortedList object automatically sort the items in alphabetic or numeric order.

Items are added to the SortedList with the Add() method. A SortedList can be sized to its final size with the TrimToSize() method.

The following code creates a SortedList named mycountries and four elements are added:

<script runat="server">

sub Page_Load

if Not Page.IsPostBack then

  dim mycountries=New SortedList

  mycountries.Add("N","Norway")

  mycountries.Add("S","Sweden")

  mycountries.Add("F","France")

  mycountries.Add("I","Italy")

  rb.DataSource=mycountries
  rb.DataValueField="Key"
  rb.DataTextField="Value"
  rb.DataBind()

end if

end sub

</script>

XML File:    We can bind XML files with List controls.

<script runat=”server”>

sub Page_Load

if Not Page.IsPostBack then

  dim mycountries=New DataSet

  mycountries.ReadXml(MapPath("countries.xml"))

  rb.DataSource=mycountries

  rb.DataValueField="value"

  rb.DataTextField="text"

  rb.DataBind()

end if

end sub

DataList Control:

           

            The DataList control is, like the Repeater control, used to display a repeated list of items that are bound to the control. However, the DataList control adds a table around the data items by default. The DataList control may be bound to a database table, an XML file, or another list of items.

How do you debug an ASP.NET Web application?

Attach the aspnet_wp.exe process to the DbgClr debugger.

What are three test cases you should go through in unit testing?

Positive test cases (correct data, correct output), negative test cases (broken or missing data, proper handling), exception test cases (exceptions are thrown and caught properly).

What are advantages and disadvantages of Microsoft-provided data provider classes in ADO.NET?

SQLServer.NET data provider is high-speed and robust, but requires SQL Server license purchased from Microsoft. OLE-DB.NET is universal for accessing other sources, like Oracle, DB2, Microsoft Access and Informix, but it’s a .NET layer on top of OLE layer, so not the fastest thing in the world. ODBC.NET is a deprecated layer provided for backward compatibility to ODBC engines.

Explain ACID rule of thumb for transactions?

 Transaction must be Atomic (it is one unit of work and does not dependent on previous and following transactions), Consistent (data is either committed or roll back, no “in-between” case where something has been updated and something hasn’t), Isolated (no transaction sees the intermediate results of the current transaction), Durable (the values persist if the data had been committed even if the system crashes right after).

What does assert() do?:

 In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.

Value type Vs. Reference type:

           

            When a datum is passed "by value" to a function, a copy of the datum is passed to the function; if the function modifies that value, the change affects only the function's copy of the datum--it does not affect the original datum.

            When a datum is passed to a function "by reference:" a reference to the value is passed to the function, and the function can use that reference to modify the value itself; any such modifications will be visible outside the function.

            The Common Language Runtime allocates memory for objects in two places: on the stack and in the heap.  The stack is an orderly first-in last-out memory structure, and is used for storing value-type objects.  When a method is invoked, the CLR bookmarks the top of the stack, and then allocates memory on top of this for any value type objects (including local variables) that are created.  When the method completes, the stack is 'popped' back to the bookmark and all the value-type objects created - and their associated memory - are released.

The heap, on the other hand, can be pictured as a disorderly jumble of objects, suitable for objects managed by reference.  When a reference-type object is created, the CLR allocates a block of heap memory, creates the object, then gives us a reference to it.  While the object itself will always be created on the heap, its reference may either exist on the heap or stack - depending on whether it’s part of another heap-object, or is a local variable.

ADO.NET

Overview:

·        Enables datacentric applications to connect to various data sources and retrieve, manipulate, and update data.

·        Uses XML to transfer data across appln  and data sources.

·        Disconnected Architecture. Using Disconnected Architecture, appln connect to database only for retrieving or updating of data. Hence reducing the No. of open connections to various database servers.

·        Dataset is a cache of records that we retrieve from data source such as XML or database file.

·        A Dataset contains data from one or more tables. In addition, a dataset contains information regarding  the relationships between tables. Enables u to remain disconnected from the database. Another adv is that components can exchange datasets.

·        A .NET dataprovider enables u to connect to a datasource and execute commands to retrieve results and manipulate data.

·        The Classes of ADO.NET are defined in the System.Data namespace. This namespace define classes, such as dataset and Datatable,  which constitute the ADO.NET architecture.

ADO.NET Architecture:

.NET Data provider

           

·         Connection

1.       Select command

2.       Insert command

3.       Update Command

4.       Delete Command

·         Command

·         DataReader

·         Data Set

1.     Datatable

·         Datacolumn

·         Datarow

·         Constraint

     2.  Datarelation

·         Database &  XML

Components of .NET data provider:

         

·         Connection

·         Command

·         Datareader – Enables to read  data in sequential manner

-  Retrieves read only, Forward only, data stream form        the database.

-  Allows us to store only one row of data on memory     at any point in time.

-  To fetch the next record, the Datareader reconnects to the datasource and retrieves the data.

·         DataAdapter- This object enables a database and dataset to communicate with each other. We can use Dataadapter object to transfer data between a data source and a dataset. In addition, the dataadapter object can transfer data between a dataset and some other applns, such Microsoft Exchange Server.

XML:

·         Is an Important component of  ADO.NET

·         ADO.NET uses XML internally to store and transfer data.

·         XML is integrated with ADO.NET as Datasets.

·         The structure of dataset, including table definitions, columns, datatypes, and constraints , is defined by using an XML schema.

·         We can serialize the dataset as XML an we can serialize the structure of dataset as XML schema.

Benefits of ADO.NET:

         

  • Interoperability
  • Maintainability
  • Programmability
  • Performance  - Ado disconnected recordsets uses COM marshalling to transfer data betn appln. This requires Datatype conversion in order for the COM to recognize the datatypes, and the conversion diminishes the performance of an appln. Alternatively, ADO.NET uses XML to transfer Data.
  • Scalability

Differences betn ADO and ADO.NET:

         

  • In-Memory, Disconnected representation of data.
  • Minimized Open connections
  • Sharing data between applications – We use COM  marshalling in ADO to transfer a disconnected recordset from one component to another. In ADO.NET, we transfer a dataset using an XML stream.

XML provides the following ADV over COM marshalling  when transferring data:

1.    Richer data type: COM marshalling can only convert data types that are defined by the COM standard. In XML- based data transfer, restrictions on datatypes do not exists. We can use XML –based data transfer to transfer any data that is serializable.

2.    By Passing Firewalls:  A Firewall does not allow system-level     requests, such as COM marshalling. Therefore, a recordset cannot bypass a firewall. However, Firewall allow HTML text to pass and we can use ADO.NET dataset through Firewall.

Notes:

       

     Though we can use OLEDB .NET data provider to access data from SQL server, we should use SQL server .Net data provider to access data from SQL server(Version 7.0 or Later).

The SQL server .Net Data provider makes Native calls  to SQL server and therefore it is more efficient than the OLEDB .NET data provider.

       

We do not need to provide the “Provider” attribute in the Connection string property for SQL connection class in the SQL server .NET data Provider.

 

The ExecuteScalar Method:                                             

The ExecuteScalar method executes a SQL statement against a specified datasource and returns a single value. The single value represents value in the first row and first column. The rest of the values are ignored.

The ExecuteScalar method is commonly used to execute aggregate

functions on a table.

The ExecuteReader Method:

       

The ExecuteReader Method executes a SQL statement or a stored procedure against a available data source and returns an OledbdataReader Object.

The ExecuteNonQuery Method:

     The ExecuteNonQuery method is used to execute INSERT, UPDATE, or DELETE statements. The ExecuteNonQuery method executes these commands and returns the no. of rows affected.

Using DataAdapters:

                  

  • An Interface between the appln and datasource for retrieving and saving data.
  • Consists of four properties that we use to specify the command objects
    1. selectCommand
    2. insertCommand
    3. updateCommand
    4. deleteCommand

Select command:

            

  • to set the SQL statement or a stored procedure that selects the data from the datasource.
  • When a select  command property does not return any value, no table is added to the dataset and no exception is thrown

Insert command:

         

  • to set the SQL statement or a stored procedure that inserts the data.
  • Returns the integer value that specifies the no. of rows affected by the corresponding operation.

Update Command:

  • To set the SQL statement or a stored procedure that updates the data.
  • It returns the no. of rows affected by the Update operation

Delete Command:

  • To set the SQL statement or a stored procedure that Deletes the Data
  • It returns the No. of rows affected by the current Delete operation

The DataReader:

         

       Enables to read  data in sequential manner.

       Retrieves read only, Forward only, data stream from the database.

       Reduces the system overhead at any time because only one row of data exists in Memory.

       To fetch the next record, the Datareader reconnects to the datasource and retrieves the data.

       After reading the Datareader using Read(), we’ve to close the Datareader.

       After closing, we can call the Isclosed() method and RecordsAffected property

DATASET:

         

  • In memory, Disconnected data architecture
  • Minimize the no. of live connections to a database
  • Collection of tables and information abt the relationship betn tables.

Creation:         

    

     Dim EmployeeDS as new dataset(“Employees”) – VB.net (or)

     Dim EmployeeDS as dataset = new Dataset()    

     Dataset EmployeeDS = new dataset(“Employees”) = C#

Adding columns to Datatable in Dataset:

     Dim Emptable as datatable = EmployeeDS.Tables.Add(“Employees”)

           

            Emptable.columns.Add(“EmployeeID”, Type.Gettype(“System.string”)

Setting Constraints on table in dataset:

     Emptable.primarykey = new datacolumn(){pkcol}

Creating Relationship betn tables in dataset:

 EmployeeDS.relations.add(“Rel_name”,EmployeeDS.Tables(“Employees”)

     .Columns(“EmployeeID”), EmployeeDS.Tables(“EmployeeTerritories”)

     .Columns(“EmployeeID”))

Note: When we create a Relationship betn a table, a unique constraint is added to the parent table, and the foreign key constraint is added to the child table by default.

Merging the contents of Dataset:

We can merge two dataset. But we’ve to remember some rules while merging

·        Check primary keys – if primary keys do not match, Exception is thrown and the dataset raises the Mergefailed Event.

·        Preserve changes – to specify whether to preserve the changes in the existing dataset. If True, the existing values in the table receiving data are not overwritten with the Incoming values. If False, the existing values in the table receiving data are not overwritten with the Incoming values in the current version of the existing row.

·        Apply constraints – Constraints are not checked when Merge method is executed. After we add the data, constraints are enforced. Therefore we need to ensure that we can handle the exceptions in our code

Dim EmpDA as SQLDataAdapter = new SQLDataAdapter(“Select * from Employee”)

Dim EmployeeDS as dataset = new Dataset()        

EmpDA.fillschema(EmpDS, Schematype.source, “Employees”)

EmpDA.Fill(EmDS, “Employees”)

Dim terds as dataset = new dataset()

Terds.readxml(“Terroitories.xml”, xmlreadmode.readschema)

Terds.acceptchanges()

Dbconn.close

EmpDS.Merge(TerDS, True, MissingSchemaAction.AddwitKey)

Copying Dataset Contents:

          Sometimes we might need to work with data without affecting the original data in the dataset. In such cases, we can create a copy of an existing dataset present in a dataset.

         

ADO.NET allows to

·         Create a exact copy of dataset including schema, data, row state information, and row version.

Dim EmployeeDS as dataset = new Dataset()        

     Dim copyDS as dataset = EmployeeDS.Copy()

·         Create a Dataset that contains the schema of an existing dataset containing only modified rows.

Dim copyDS as dataset = EmployeeDS.Getchanges()

·         Copy only the schema or relational structure of a dataset but nt any rows from the original dataset.

Dim copyDS as dataset = EmployeeDS.Clone()

Creating DataViews:

          Like a Database, a Dataset allows us to create a view. However Unlike database view, we cannot

·         Treat a Dataview as a table

·         Create a view of joined tables by using dataview.

·         Exclude or append columns that are present , and not present in the source table respectively.

Dim EmployeeDV as dataview = new dataview(EmployeeDS.tables(“Employees”), “Country=’USA’ “, “City”, Dataviewrowstate.currentrows)

(Or)

       Dim EmployeeDV as dataview = new dataview(EmployeeDS.tables(“Employees”))

     

EmployeeDV.Sort = “City”

EmployeeDV.Rowfilter = “Country = ‘USA’ ”

     

Handling ADO.NET Dataset Events:

          ADO.NET supports event-driven programming, which enables us to capture the changes and react to them properly.

Mergefailed event: ( Has two property namely Conflict Property and Table property)

Conflict property – identifies the Conflict

Table Property – identify the table name in conflict

Dim EmployeeDS as dataset = new Dataset()

Addhandler EmployeeDS.Mergefailed, New MergefailedEventHandler(Addressof DataSetMergeFailed)

Private shared sub DataSetMergeFailed(sender as object, args as MergedFailedEventArgs)

Console.WriteLine(“Merge failed for table” & args.table.tabelName)

Console.WriteLine(“Conflict=” &args.Conflict)

End sub

Events of the datatable object:

Event 

Description

Columnchanged

This Event occurs when we successfully insert a value in column

ColumnChanging

When we submit a value for a column

RowChanged

After we edit a row

Rowchanging

When a row in a table is changing

RowDeleted

After a row is deleted

RowDeleting

Before we delete a row.

Creating a Typed ADO.NET Dataset:

  • Unlike untyped Dataset that does not have an XML schema associated with it, a strongly typed dataset does have a XML  schema associated with it.
  • Allow us to access tables and columns using user-friendly names and strongly typed variables
  • A TYPED DATASET IS A CLASS THAT DERIVES FROM A DATASET. The Strongly typed dataset inherits all the methods, events , and properties of a dataset. In addition, it provides with strongly typed methods, events and properties. This enables us to access the tables and columns by their names instead of using collection-based methods. This feature improves the readability of our code and allow the .Net code editor to provide the Intellisense technology , which automatically completes the statements as we type.
  • The Intellisense technology increases the quality of our code because it corrects type mismatch at compile time rather than at runtime.
  • We can create the strongly typed dataset using the following Command-line utility XSD.exe

Xsd.exe /d /1:CS XSDSchemaFileName.xsd /n:XSDSchema.NameSpace

For a programming language to be a true OOP language, the language must meet the following criteria:

Abstraction—Abstraction manages the complexities of a business problem by allowing you to identify a set of objects involved with that business problem.

Encapsulation—Encapsulation hides the internal implementation of an abstraction within the particular object.

Polymorphism—Polymorphism provides for multiple implementations of the same method. For example, different objects can have a Save method, each of which perform different processing.

Inheritance—The excitement of Visual Basic .NET lies in inheritance. Visual Basic 5 introduced the concept of interface inheritance, which allows you to reuse the interface of a class, but not its implementation. Visual Basic .NET provides for true implementation inheritance whereby you can reuse the implementation of a class.

More Questiona and Answers

1.) True/False A web Service can only be written in .NET? Explain?

A. False. .NET Framework is one of the technologies that could be used create webservices.

2.) What property do you have to set to tell the grid which page to go to when using the Pager object?

A. CurrentPageIndex. You need to set this one with the DataGridPageChangedEventArgs' NewPageIndex.

3.) What tags do you need to add within the <asp:datagrid> tags to bind columns manually.

A. Set AutoGenerateColumns Property to false on the datagrid tag

4.) Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?

A. it goes like this ListBox.DataSource = DataSet Name; ListBox.DataBind();

5.) How is a property designated as read-only?

A. If it has only get accessor.

ex:
public class abc
{
private string stringIt="This is the string";
public string StringIt
{
get
{
return stringIt;
}
}
}

But you could set an attribute prior to the property name with [ReadOnly="true"],
if that property defined an attribute

6.) Where on the Internet would you look for Web services?
Somebody told me it is UDDI server. what actually is UDDI?

A. UDDI is Universal Description, Discovery and Integration of Web Services.
The UDDI servers serves as yellow pages to WebServices (visit
http://www.uddi.org)

7.) Which control would you use if you needed to make sure the values in two different controls matched?

A. Use CompareValidator

8.) True or False: To test a Web service you must create a windows application or Web application to consume this service?

A. No need, the webservice comes with a test page and it provides HTTP-GET method to test.
And if the web service turned off HTTP-GET for security purposes then you need to create
a web application or windows app as a client to this to test.

9.) How many classes can a single .NET DLL contain?
(a) One and only one
(b) Not more than 2
(c) Many

A. (c). many is correct. Yes an assembly can contain one or more classes and an assembly can
be contained in one dll or could spread across multiple dlls. too. Take System.dll, it is
collections of so many classes.


10.) What is the transport protocol you use to call a Web service? Is it SOAP or HTTP-Get or HTTP-Post???

A. You could use all the three, but SOAP is the preferred and secured method of consuming the  Service.

11.) What is WSDL?

A. WSDL is web services description language, which is used to define the webservice.

 



Electronics  rf design  VLSI   Free IEEE papers  VLSI Interview  RFIC Technologies RF design RSS