Friday, September 26, 2008

ASP.NET7

pre- and/or post-processed. 

How does CAS work?

The CAS security policy revolves around two key concepts - code groups and permissions. Each

.NET assembly is a member of a particular code group, and each code group is granted the

permissions specified in a named permission set.

For example, using the default security policy, a control downloaded from a web site belongs to the

‘Zone - Internet‘ code group, which adheres to the permissions defined by the ‘Internet‘ named

permission set. (Naturally the ‘Internet‘ named permission set represents a very restrictive range

of permissions.) 

Who defines the CAS code groups?

Microsoft defines some default ones, but you can modify these and even create your own. To see the

code groups defined on your system, run ‘caspol -lg‘ from the command-line. On my system it looks

like this:

Level 3 Machine

Code Groups:

1.  All code: Nothing

1.1.  Zone - MyComputer: FullTrust

1.1.1.  Honor SkipVerification requests: SkipVerification

1.2.  Zone - Intranet: LocalIntranet

1.3.  Zone - Internet: Internet

1.4.  Zone - Untrusted: Nothing

1.5.  Zone - Trusted: Internet

1.6.  StrongName - 0024000004800000940000000602000000240000525341310004000003

000000CFCB3291AA715FE99D40D49040336F9056D7886FED46775BC7BB5430BA4444FEF8348EBD06

F962F39776AE4DC3B7B04A7FE6F49F25F740423EBF2C0B89698D8D08AC48D69CED0FC8F83B465E0

8

07AC11EC1DCC7D054E807A43336DDE408A5393A48556123272CEEEE72F1660B71927D38561AABF5

C AC1DF1734633C602F8F2D5:

Note the hierarchy of code groups - the top of the hierarchy is the most general (‘All code‘),

which is then sub-divided into several

groups, each of which in turn can be sub-divided. Also note that (somewhat counter-intuitively)

a sub-group  can be associated with a more permissive permission set than its parent. 

How do I define my own  code group?

Use caspol. For example, suppose you trust code from  www.mydomain.com and you want it have full

access to your system, but you want to keep the default restrictions for all other internet sites.

To achieve this, you would add a new code group as a sub-group  of the

‘Zone - Internet‘ group, like this:

caspol -ag 1.3 -site www.mydomain.com FullTrust

Now if you run caspol -lg you will see that the new group has been added as group 1.3.1: 

1.3.  Zone - Internet: Internet

1.3.1.  Site -  www.mydomain.com: FullTrust 

Note that the numeric label (1.3.1) is just a caspol invention to make the code groups easy to

manipulate from the command-line. The underlying runtime never sees it. 

How do I change the permission set for a code group?

Use caspol. If you are the machine administrator, you can operate at the ‘machine‘ level -

which means not only that the changes you make become the default for the machine, but also

that users cannot change the permissions to be more permissive. If you are a normal (non- admin)

user you can still modify the permissions, but only to make them more restrictive. For example, to

allow intranet code to do what it likes you might do this:

caspol -cg 1.2 FullTrust

Note that because this is more permissive than the default policy (on a standard system), you

should only do this at the machine level - doing it at the user level will have no effect. 

I can‘t be bothered with aLL this CAS stuff. Can I turn it off?

Yes, as long as you are an administrator. Just run: caspol -s off 

Can I Look at the IL for an assembLy?

Yes. MS supply a tool called Ildasm which can be used to view the metadata and IL for an assembly. 

Can source code be reverse-engineered from IL?

Yes, it is often relatively straightforward to regenerate high-level source (e.g. C#) from IL. 

How can I stop my code being reverse-engineered from IL?

There is currently no simple way to stop code being reverse-engineered from IL. In future it is

likely that IL obfuscation tools will become available, either from MS or from third parties. These

tools work by ‘optimising‘ the IL in such a way that reverse-engineering becomes much more

difficult.

Of course if you are writing web services then reverse-engineering is not a problem as clients do

not have access to your IL. 

Is there buiLt-in support for tracing/Logging?

Yes, in the System.Diagnostics namespace. There are two main classes that deal with tracing - Debug

and Trace. They both work in a similar way - the difference is that tracing from the Debug class

only works in builds that have the DEBUG symbol defined, whereas tracing from the Trace class only

works in builds that have the TRACE symbol defined. Typically this means that you should use

System.Diagnostics.Trace.WriteLine for tracing that you want to work in debug and release builds,

and System.Diagnostics.Debug.WriteLine for tracing that you want to work only in debug builds. 

Can I redirect tracing to a fiLe?

Yes. The Debug and Trace classes both have a Listeners property, which is a collection of sinks

that receive the tracing that you send via Debug.WriteLine and Trace.WriteLine respectively. By

default the Listeners collection contains a single sink, which is an

instance of the DefaultTraceListener class. This sends output to the Win32 OutputDebugString()

function and also the System.Diagnostics.Debugger.Log() method. This is useful when debugging, but

if you‘re trying to trace a problem at a customer site, redirecting the output to

a file is more appropriate. Fortunately, the TextWriterTraceListener class is provided for this

purpose. 

What are the contents of assembLy?

In general, a static assembly can consist of four elements: The assembly manifest, which contains

assembly metadata. Type metadata.

Microsoft intermediate language (MSIL) code that implements the types. A set of resources. 

What is GC (Garbage CoLLection) and how it works

One of the good features of the CLR is Garbage Collection, which runs in the background collecting

unused object references, freeing us from having to ensure we always destroy them.

In reality the time difference between you releasing the object instance and it being garbage

collected is likely to be very small, since the GC is always running.

[The process of transitively tracing through all pointers to actively used objects in order to

locate all objects that can be referenced, and then arranging to reuse any heap memory that was not

found  during this trace. The common  language runtime garbage collector also compacts the memory

that is in use to reduce the working space needed for the heap.] 

Heap:

A portion of memory reserved for a program to use for the temporary storage of data structures

whose existence or size cannot be determined until the program is running. 

Differnce between Managed code and unmanaged code ?

Managed Code:

Code that runs under a ”contract of cooperation” with the common  language runtime. Managed code

must supply the metadata necessary for the runtime to provide services such as memory management,

cross-language integration, code access security, and

automatic lifetime control of objects. All code based on Microsoft intermediate language (MSIL)

executes as managed code. 

Un-Managed Code:

Code that is created without regard for the conventions and requirements of the common language

runtime. Unmanaged code executes in the common  language runtime environment with minimal services

(for example, no garbage collection, limited debugging, and so on). 

What is MSIL, IL, CTS and, CLR ? 

MSIL: (Microsoft intermediate language)

When compiling to managed code, the compiler translates your source code into Microsoft

intermediate language (MSIL), which is a CPU-independent set of instructions that can be

efficiently converted to native code. MSIL includes instructions for loading, storing,

initializing, and calling methods on objects, as well as instructions for arithmetic and logical

operations, control flow, direct memory access, exception handling, and other operations. Before

code can be executed, MSIL must be converted to CPU-specific code, usually by a just-in-time (JIT)

compiler. Because the common  language runtime supplies one or more JIT compilers for each computer

architecture it supports, the same set of MSIL can be JIT-compiled and executed on any supported

architecture.

When a compiler produces MSIL, it also produces metadata. Metadata describes the types in

your code, including the definition of

each type, the signatures of each type‘s members, the members that your code references, and other

data that the runtime uses at

execution time. The MSIL and metadata are contained in a portable executable (PE) file that is

based on and extends the published

Microsoft PE and Common Object File Format (COFF) used historically for executable content. This

file format, which accommodates 

MSIL or native code as well as metadata, enables the operating system to recognize common language

runtime images. The

presence of metadata in the file along with the MSIL enables your code to describe itself,

which means that there is no need for type libraries or Interface Definition Language (IDL). The

runtime locates and extracts the metadata from the file as needed during

execution. 

IL: (Intermediate Language)

A language used as the output of a number of compilers and as the input to a just-in-time (JIT)

compiler. The common  language

runtime includes a JIT compiler for converting MSIL to native code. 

CTS: (Common Type System)

The specification that determines how the common  language runtime defines, uses, and manages types 

CLR: (Common Language Runtime)

The engine at the core of managed code execution. The runtime supplies managed code with services

such as cross-language

integration, code access security, object lifetime management, and debugging and profiling support. 

What is Reference type and vaLue type ?

Reference Type:

Reference types are allocated on the managed CLR heap, just like object types.

A data type that is stored as a reference to the value‘s location. The value of a reference type is

the location of the sequence of bits

that represent the type‘s data. Reference types can be self-describing types, pointer types, or

interface types

 

ASP.NET6

>>Changes to which portion of version number indicates an incompatible change?
Major or minor. Changes to the major or minor portion of the version number indicate an
incompatible change. Under this convention then, version 2.0.0.0 would be considered incompatible
with version 1.0.0.0. Examples of an incompatible change would be a change to the types of some
method parameters or the removal of a type or method altogether. Build. The Build number is
typically used to distinguish between daily builds or smaller compatible releases. Revision.
Changes to the revision number are typically reserved for an incremental build needed to fix a
particular bug. You‘ll sometimes hear this referred to as the ”emergency bug fix” number in that
the revision is what is often changed when a fix to a specific bug is shipped to a customer.
>>What is side-by-side execution?
           Can two application one using private assembly and other using 
>>Shared assembly be stated as a side-by-side executables?
Side-by-side execution is the ability to run multiple versions of an application or component on
the same computer. You can have multiple versions of the common language runtime, and multiple
versions of applications and components that use a version of the runtime, on the same computer at
the same time. Since versioning is only applied to shared assemblies, and
not to private assemblies, two application one using private assembly and one using shared assembly
cannot be stated as side-by-side
executables.
>>Why string are called Immutable data Type ?
The memory representation of string is an Array of Characters, So on re-assigning the new array of
Char is formed a the start address is changed . Thus keeping the Old string in Memory for Garbage
Collector to be disposed.

>>What does assert() method 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.

>>What‘s the difference between the Debug class and Trace class?
Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and
release builds.

>>Why are there five tracing levels in System.Diagnostics.TraceSwitcher?
The tracing dumps can be quite verbose. For applications that are constantly running you run the
risk of overloading the machine and the hard drive. Five levels range from None to Verbose,
allowing you to fine-tune the tracing activities.

>>Where is the output of TextWriterTraceListener redirected?
To the Console or a text file depending on the parameter passed to the constructor.

>>How do assemblies find each other?
By searching directory paths. There are several factors which can affect the path (such as the
AppDomain host, and application configuration files), but for private assemblies the search path is
normally the application‘s directory and its sub-directories. For shared assemblies, the search
path is normally same as the private assembly path plus the shared assembly cache.

>>How does assembly versioning work?
Each assembly has a version number called the compatibility version. Also each reference to an
assembly (from another assembly) includes both the name and version of the referenced assembly.The
version number has four numeric parts (e.g. 5.5.2.33). Assemblies with either of the first two
parts different are normally viewed as incompatible. If the first two parts are the same, but the
third is different, the assemblies are deemed as ‘maybe compatible‘. If only the fourth part is
different, the assemblies are deemed compatible. However, this is just the default guideline - it
is the version policy that decides to what extent these rules are enforced. The version policy can
be specified via the application configuration file.

>>What is an Application Domain?
An AppDomain can be thought of as a lightweight process. Multiple AppDomains can exist inside a
Win32 process. The primary purpose of the AppDomain is to isolate an application from other
applications. Win32 processes provide isolation by having distinct memory address spaces. This is
effective, but it is expensive and doesn‘t scale well. The .NET runtime enforces AppDomain
isolation by keeping control over the use of memory - all memory in the AppDomain is managed by the
.NET runtime, so the runtime can ensure that AppDomains do not access each other‘s memory.

>>What is garbage collection?
Garbage collection is a system whereby a run-time component takes responsibility for managing the
lifetime of objects and the heap memory that they occupy. This concept is not new to .NET - Java
and many other languages/runtimes have used garbage collection for some time.

>>Why doesn‘t the .NET runtime offer deterministic destruction?
Because of the garbage collection algorithm. The .NET garbage collector works by periodically
running through a list of all the objects that are currently being referenced by an application.
All the objects that it doesn’t find during this search are ready to be destroyed and the memory
reclaimed. The implication of this algorithm is that the runtime doesn’t get notified
immediately when the final reference on an object goes away - it only finds out during the next
sweep of the heap.
Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely
as possible. Normally heap exhaustion is the trigger for a collection sweep.

>>Is the Lack of deterministic destruction in .NET a probLem?
lt’s certainly an issue that affects component design. lf you have objects that maintain expensive
or scarce resources (e.g. database locks), you need to provide some way for the client to tell the
object to release the resource when it is done. Microsoft recommend that you provide a method
called Dispose() for this purpose. However, this causes problems for distributed objects - in a
distributed system who calls the Dispose() method? Some form of reference-counting or
ownership-management mechanism is needed to handle distributed objects - unfortunately the runtime
offers no help with this.
>>What is seriaLization?
Serialization is the process of converting an object into a stream of bytes. Deserialization is the
opposite process of creating an object from a stream of bytes. Serialization / Deserialization is
mostly used to transport objects (e.g. during remoting), or to persist
objects (e.g. to a file or database).
>>Does the .NET Framework have in-buiLt support for seriaLization?
There are two separate mechanisms provided by the .NET class library - XmlSerializer and
SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses
SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code.

>>Can I customise the seriaLization process?
Yes. XmlSerializer supports a range of attributes that can be used to configure serialization for a
particular class. For example, a field or property can be marked with the [Xmllgnore] attribute to
exclude it from serialization. Another example is the [XmlElement]
attribute, which can be used to specify the XML element name to be used for a particular
property or field.
Serialization via SoapFormatter/BinaryFormatter can also be controlled to some extent by
attributes. For example, the [NonSerialized] attribute is the equivalent of XmlSerializer’s
[Xmllgnore] attribute. Ultimate control of the serialization process can be acheived by
implementing the the lSerializable interface on the class whose instances are to be serialized.

>>Why is XmLSeriaLizer so sLow?
There is a once-per-process-per-type overhead with XmlSerializer. So the first time you serialize
or deserialize an object of a given type in an application, there is a significant delay. This
normally doesn’t matter, but it may mean, for example, that XmlSerializer is a poor choice for
loading configuration settings during startup of a GUl application.

>>Why do I get errors when I try to seriaLize a HashtabLe?
XmlSerializer will refuse to serialize instances of any class that implements lDictionary, e.g.
Hashtable. SoapFormatter and BinaryFormatter do not have this restriction.

>>What are attributes?
There are at least two types of .NET attribute. The first type l will refer to as a metadata
attribute - it allows some data to be attached to a class or method. This data becomes part of the
metadata for the class, and (like other class metadata) can be accessed via reflection.
The other type of attribute is a context attribute. Context attributes use a similar syntax to
metadata attributes but they are fundamentally different. Context attributes provide an
interception mechanism whereby instance activation and method calls can be





ASP.NET5

15.What is the CTS?

CTS 3 Common Type System. This is the range of types that the .NET runtime understands, and

therefore that .NET applications can use. However note that not all .NET languages will

support all the types in the CTS. The CTS is a superset of the CLS. 

16.What is the CLS?

CLS 3 Common Language Specification. This is a subset of the CTS which all .NET languages are

expected to support. The idea is that any program which uses CLS-compliant types can interoperate

17.with any .NET program written in any language.

In theory this allows very tight interop between different .NET languages - for example allowing a

C# class to inherit from a VB class. 

18.What is IL?

IL 3 Intermediate Language. Also known as MSIL (Microsoft Intermediate Language) or CIL (Common

Intermediate Language). All .NET source code (of any language) is compiled to IL. The IL is then

converted to machine code at the point where the software is installed, or at run-time by a

Just-In-Time (JIT) compiler. 

19.What does ‘managed‘ mean in the .NET context?

The term ‘managed‘ is the cause of much confusion. It is used in various places within .NET,

meaning slightly different things.Managed code: The .NET framework provides several core run- time

services to the programs that run within it - for example

exception handling and security. For these services to work, the code must provide a minimum level

of information to the runtime.

Such code is called managed code. All C# and Visual Basic.NET code is managed by default. VS7

C++ code is not managed by default, but the compiler can produce managed code by specifying a

command-line switch (/com+).

Managed data: This is data that is allocated and de-allocated by the .NET runtime‘s garbage

collector. C# and VB.NET data is always managed. VS7 C++ data is unmanaged by default, even when

using the /com+ switch, but it can be marked as managed using the    gc keyword.

Managed classes:

This is usually referred to in the context of Managed Extensions (ME) for C++. When using ME C++, a

class can be marked with the    gc keyword. As the name suggests, this means that the memory for

instances of the class is managed by the garbage collector, but it also means more than that. The

class becomes a fully paid-up member of the

.NET community with the benefits and restrictions that brings. An example of a benefit is proper

interop with classes written in other languages - for example, a managed C++ class can inherit from

a VB class. An example of a restriction is that a managed class can only inherit from one base

class. 

20.What is reflection?

All .NET compilers produce metadata about the types defined in the modules they produce. This

metadata is packaged along with the module (modules in turn are packaged together in assemblies),

and can be accessed by a mechanism called reflection. The System.Reflection namespace contains

classes that can be used to interrogate the types for a module/assembly. Using reflection to access

.NET metadata is very similar to using ITypeLib/ITypeInfo to access type library data in COM, and

it is used for similar purposes - e.g. determining data type sizes for marshaling data across

context/process/machine boundaries.

Reflection can also be used to dynamically invoke methods (see System.Type.InvokeMember ) , or even

create types dynamically at run-time (see System.Reflection.Emit.TypeBuilder).

 

21.What is the difference between Finalize and Dispose (Garbage collection) ?

Class instances often encapsulate control over resources that are not managed by the runtime, such

as window handles (HWND), database connections, and so on. Therefore, you should provide both an

explicit and an implicit way to free those resources. Provide implicit control by implementing the

protected Finalize Method on an object (destructor syntax in C# and the Managed Extensions for

C++). The garbage collector calls this method at some point after there are no longer any valid

references to the object. In some cases, you might want to provide programmers using an object with

the ability to explicitly release these external resources before the garbage collector frees the

object. If an external resource is scarce or expensive, better performance can be achieved if the

programmer explicitly releases resources when they are no longer being used. To provide explicit

control, implement the Dispose method provided by the IDisposable Interface. The consumer of the

object should call this method when it is

done using the object.

Dispose can be called even if other references to the object are alive. Note that even when you

provide explicit control by way of Dispose, you should provide implicit cleanup using the

Finalize method. Finalize provides a backup to prevent resources from

Permanently leaking if the programmer fails to call Dispose. 

22.What is Partial Assembly References?

Full Assembly reference: A full assembly reference includes the assembly‘s text name, version,

culture, and public key token (if the assembly has a strong name). A full assembly reference is

required if you reference any assembly that is part of the common

Language runtime or any assembly located in the global assembly cache. 

Partial Assembly reference: We can dynamically reference an assembly by providing  only partial

information, such as specifying only the assembly name. When you specify a partial assembly

reference, the runtime looks for the assembly only in the application

Directory.

We can make partial references to an assembly in your code one of the following ways:

-> Use a method such as System.Reflection.Assembly.Load and specify only a partial reference. The

runtime checks for the assembly in the application directory.

-> Use the System.Reflection.Assembly.LoadWithPartialName method and specify only a partial

reference. The runtime checks for the assembly in the application directory and in the global

assembly cache

ASP.NET4

 10.     Server.Transfer V/s Response.Redirect

A:  Response.Redirect  simply  sends a  message down  to  the  browser,  telling  it  to  move  to

another        page.       So,        you       can      run,       

Response.Redirect(”WebForm2.aspx”)       or Response.Redirect(”http:99www.karlmoore.com9”) 

Server.Transfer  is similar  in that it  sends the  user to  another  page with  a statement  such 

as Server.Transfer(”WebForm2.aspx”).    But    transferring    to    another    page   conserves  

server resources. Instead of telling the browser to  redirect, it simply changes the ”focus” on the

Web server and transfers the request. This means you don’t get quite as many HTTP requests coming

through,  which  therefore  eases the  pressure on your  Web  server  and makes your  applications

run  faster.  But  remember,  you can’t  use Server.Transfer  to  send the  user to  an external 

site. Secondly,  Server.Transfer  maintains  the  original  URL  in  the  browser.  This  can 

really  help streamline data entry techniques, although it may make for confusion  when debugging.

 

That’s not all: The Server.Transfer method also has a second parameterH”preserveForm”. If you set  

this   to   True,  using  a  statement   such   as  Server.Transfer(”WebForm2.aspx”,  True),  the

existing   query  string   and  any  form   variables   will   still  be  available  to   the  page

 you  are transferring to. For example, if your WebForm1.aspx has a TextBox control called TextBox1

and you transferred to WebForm2.aspx with the preserveForm parameter set to True, you’d be able to 

   retrieve     the     value     of     the     original     page    TextBox     control     by   

 referencing Request.Form(”TextBox1”). 

Q: Introduction to .Net configuration (machine.config and other config files) Q: Session mangment

(Web.config’s Session State and cookie less session etc.) Q: Authentication and Authorization

(Forms, Windows a Passport Authentication and in depth Form Auth.) Q: Global.aspx

Q: Caching (cache attribute, fragment caching, cache object) Q: Value Type and Ref. Type (Boxing

and Un-boxing)

Q: Structure and classes, Difference? Q: Interface and classes, Difference?

Q: Class properties, methods and data members

Q: What the internal data member?

Q: What is difference between const and static readonly? Q: Overload and override

methods9properties?

Q: Abstract, virtual, override, new, sealed etc. keywords for method9property9class

Q: What is inheritance, abstraction etc. OOPs and real life example? Q: What is .Net framework,

CLR, class library, MSIL etc.

Q: What is assembly and how to create global assembly? Q: What are the objects of ADO.NET?

Q: What is difference between Reader and Dataset? Q: How to add relation in dataset’s 2 tables?

OOPs

 

12.What is object? What is class?

What are members? data, properties, methods, events

Access modifiers

Static members, static constructor

Overloading (parameters, return type etc. out) Constructors and distructor

Encapsulation (Data hinding)

through method or properties

Inheritance

Simple and multilevel inheritance

Interface and multiple inheritance

Polymorphism

virtual and override

method hiding with new key word abstract and sealed methods/classes 

13.When was .NET announced?

Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET ‘vision‘. The

July 2000 PDC had a number of sessions on .NET technology, and delegates were given CDs containing

a pre-release version of the .NET framework/SDK and Visual Studio.NET. 

14.When was the first version of .NET reLeased?

The final version of the 1.0 SDK and runtime was made publicly available around 6pm PST on

15-Jan-2002. At the same time, the final version of Visual Studio.NET was made available to

MSDN subscribers. 

15.What pLatforms do the .NET Framework run on?

The runtime supports Windows XP, Windows 2000, NT4 SP6a and Windows ME/98. Windows 95 is not

supported. Some parts of the framework do not work on all platforms - for example, ASP.NET is only

supported on Windows XP and Windows 2000. Windows 98/ME cannot be used for development.

IIS is not supported on Windows XP Home Edition, and so cannot be used to host ASP.NET.

However, the ASP.NET Web Matrix web server does run on XP Home.

The Mono project is attempting to implement the .NET framework on Linux. 

16.What is the CLR?

CLR 3 Common Language Runtime. The CLR is a set of standard resources that (in theory) any

.NET program can take advantage of, regardless of programming language. Robert Schmidt

(Microsoft) lists the following CLR resources in his MSDN PDC# article:

Object-oriented programming model (inheritance, polymorphism, exception handling, garbage

collection)

 Security model 

 Type system 

  ll  NET base classes 

 Many  NET framework classes 

 Development, debugging, and profiling tools 

 Execution and code management 

 IL-to-native translators and optimizers

What this means is that in the .NET world, different programming languages will be more equal

in capability than they have ever been before, although clearly not all languages will support all

CLR services.

ASP.NET 3

  1.    Page Life Cycle 

A: Stages and corresponding events in the life cycle of the ASP.NET page cycle:

•     Page Initialization (Page Init)

•     View State Loading (LoadViewState)

•     Post-Back data processing (LoadPostData)

•     Page Loading (Page Load)

•     Post-Back Change Notification (RaisePostDataChangedEvent)

•     Post-Back Event Handling (RaisePostBackEvent)

•     Page Pre Rendering Phase (Page PreRender)

•     View State Saving (SaveViewState)

•     Page Rendering  (Page Render) 

•     Page Unloading (Page UnLoad)

2.   ASP.NET Web server controls, HTML server controls and HTML Intrinsic Controls

A:

ASP.NET Server Controls

•     They detect the target browser’s capabilities and render themselves accordingly.  

•    Processing would be done at the server side. In built functionality to check for few values

(with Validation controls) so no need to choose between scripting language which would be

incompatible with few browsers.

•     They have an object model different from the traditional HTML and even provide a set of

properties and methods that can change the look a behavior of the controls.

•    They have higher level of abstraction. An output of such control can be the result of many

HTML tags that combine together to produce that control and its events.

•     Not much of direct control on these controls as the code is inbuilt.

•     They have higher level of abstraction, which increase overhead on server side.

•     Migration of ASP to any ASP.NET application is difficult. 

 

3.HTML Server Controls

•     They have no mechanism of identifying the capabilities of the client browser.

•     They follow the HTML-centric object model. 

•     The controls can be made to interact with Client side scripting (depends).

•     Migration of the ASP project thought not very easy but can be done by adding

runat3server to all HTML tags in ASP. 

4.HTML Intrinsic Controls

•     Model similar to HTML

•     They can directly interact with Client side scripting

•     On server side, it’s considered as plain texts only so not much control over it on server

side. 

 5.  Validator controls

A: 

•     RequiredFieldValidator

•     CompareValidator

•     RangeValidator

•     RegularExpressionValidator

•     CustomValidator

All Validator controls require control to validate except CustomValidator. These Controls validate

on server as well as client depending on client browser. For CustomValidator, we need to implement

validation logic on client9server9both. 

6.   User Controls

A:  The ASP.NET  server  controLs  provide a great  deaL  of  functionaLity,  but  they  cannot 

cover every situation.  Web  user controLs  enabLe  you to  easiLy  define controLs  as you need

them  for your appLications, using the same programming techniques that you use to write. The

extension must  be .ASCX  and they  generaLLy  don’t  have and tags.  The LifecycLe 

of user controLs is simiLar to page LifecycLe.

The controLs can be Loaded staticaLLy or dynamicaLLy. When a controL is created dynamicaLLy at run

time, some information about the controL is stored in the view state that is rendered with the 

page.  When  the  page is posted  back to  the  server,  however,  non-dynamic controLs  (those

defined on  the  page) are  instantiated  in  the  Page.Init  event  and  view state  information 

is Loaded  before the  dynamic controLs  can be recreated  (generaLLy  in  the  Page_Load 

handLer). EffectiveLy,  before the  dynamic controLs  are recreated,  view state  is temporariLy 

out  of sync with the page’s controLs. After the Page_Load event has run, but before controL event

handLing methods  are  caLLed,  the  remaining  view  state  information  is  Loaded  into  the 

dynamicaLLy created controLs.

In  most  scenarios,  this  view state  processing modeL  works  fine.  TypicaLLy,  you  add

dynamic controLs to the end of a container’s coLLection of controLs. The view state information

stored for the  dynamic controLs  is therefore extra  information  at the  end of the view state

structure for the appropriate container, and the page can ignore it untiL after the controLs are

created.

7.   View-State 

View state is stored in a hidden fieLd on each ASP.NET page caLLed    VIEWSTATE. Each time a page

is posted to itseLf, the contents of the    VIEWSTATE fieLd are sent as part of the post. The

primary use of view state is for controLs to retain their state across post-backs. The view state

is packed with the page. So it inevitabLy adds a few extra kiLobytes of data to the payLoad. A

compLex, reaL-worLd page can easiLy find 10KB of extra stuff packed in the HTML code sent to the

browser. It’s composed of pLain text (in base64 format) and it couLd be tampered, so it is not

recommended to store sensitive data in the view state (credit card numbers and passwords etc.)

 8.  Post-Back

A: Post-Back is a mechanism that enabLe us to do server-side actions. Some actions can be handLed

on the cLient side, meaning they don’t require

anything to be processed on the server side. (For exampLe showing a mouseover

image effect.) On the other hand, sometimes you need to do more compLex things which you cannot do

on the cLient side. (For exampLe, changing a data source on the server side.) Because of this need,

there’s the postback mechanism. The page “posts“ back the page to the server. (As the name impLies,

this is a POST, not a GET). I recommend that you use the foLLowing Link as a starting point to get

more insight how pages are processed and the event modeL; 

   Inline V/s Code-Behind

A: ASP.NET supports two modes of page deveLopment:

•    Page Logic code that is written inside

Wednesday, September 24, 2008

SQl SErver

SQL Server, DBA interview questions Database
A site visitor writes: Here are some SQL Server DBA/Developer interview questions I faced myself personally and/or heard from people. I will try to answer these questions briefly here, but be advised that these answers may not be complete and it will be better for you to go through text books, books online and other resources on the net.
Before you go for the interview, be prepared to explain the database design of one of your latest projects. Don’t be surprised if the interviewer asks you to draw ER diagrams.
Well, here are some questions for you. Hope this helps you prepare for your interview. Wish you all the best in your job hunt! Feel free to email me ‘interview questions’ that you’ve faced.
Questions are categorized under the following sections, for your convenience:
Database design (8 questions)
SQL Server architecture (12 questions)
Database administration (13 questions)
Database programming (10 questions)
Database design

What is normalization? Explain different levels of normalization?
Check out the article Q100139 from Microsoft knowledge base and of course, there’s much more information available in the net. It’ll be a good idea to get a hold of any RDBMS fundamentals text book, especially the one by C. J. Date. Most of the times, it will be okay if you can explain till third normal form.
What is denormalization and when would you go for it?
As the name indicates, denormalization is the reverse process of normalization. It’s the controlled introduction of redundancy in to the database design. It helps improve the query performance as the number of joins could be reduced.
How do you implement one-to-one, one-to-many and many-to-many relationships while designing tables?
One-to-One relationship can be implemented as a single table and rarely as two tables with primary and foreign key relationships. One-to-Many relationships are implemented by splitting the data into two tables with primary key and foreign key relationships. Many-to-Many relationships are implemented using a junction table with the keys from both the tables forming the composite primary key of the junction table. It will be a good idea to read up a database designing fundamentals text book.

Asp.net IQ2

What are the main differences between asp and asp.net?
Ans: ASP 3.0
Supports VBScript and JavaScript
scripting languages are limited in scope
interpreted from top to bottom each time the page is loaded
Files end with *.asp extension
5 objects: Request, Response, Server, Application, Session
Queried databases return recordsets
Uses conventional HTML forms for data collection
ASP .NET
Supports a number of languages including Visual Basic, C#, and JScript
code is compiled into .NET classes and stored to speed up multiple hits on a page
object oriented and event driven makes coding web pages more like traditional applications
Files end with *.aspx extension
.NET contains over 3400 classes
XML-friendly data sets are used instead of recordsets
Uses web forms that look like HTML forms to the client, but add much functionality due to server-side coding
Has built-in validation objects
Improved debugging feature (great news for programmers)
ASP .NET controls can be binded to a data source, including XML recordsets
Source: mikekissman.com
What is a user control?

Ans: An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user's previous work experience).
Source: 15seconds.com
What are different types of controls available in ASP.net?
Ans: HTML server controls HTML elements exposed to the server so you can program them. HTML server controls expose an object model that maps very closely to the HTML elements that they render.
Web server controls Controls with more built-in features than HTML server controls. Web server controls include not only form-type controls such as buttons and text boxes, but also special-purpose controls such as a calendar. Web server controls are more abstract than HTML server controls in that their object model does not necessarily reflect HTML syntax.
Validation controls Controls that incorporate logic to allow you to test a user's input. You attach a validation control to an input control to test what the user enters for that input control. Validation controls are provided to allow you to check for a required field, to test against a specific value or pattern of characters, to verify that a value lies within a range, and so on.
User controls Controls that you create as Web Forms pages. You can embed Web Forms user controls in other Web Forms pages, which is an easy way to create menus, toolbars, and other reusable elements.
Note You can also create output for mobile devices. To do so, you use the same ASP.NET page framework, but you create Mobile Web Forms instead of Web Forms pages and use controls specifically designed for mobile devices.
Source: MSDN
What are the validation controls available in ASP.net?
Ans:
Type of validation
Control to use
Description
Required entry
RequiredFieldValidator
Ensures that the user does not skip an entry.
Comparison to a value
CompareValidator
Compares a user's entry against a constant value, or against a property value of another control, using a comparison operator (less than, equal, greater than, and so on).
Range checking
RangeValidator
Checks that a user's entry is between specified lower and upper boundaries. You can check ranges within pairs of numbers, alphabetic characters, and dates.
Pattern matching
RegularExpressionValidator
Checks that the entry matches a pattern defined by a regular expression. This type of validation allows you to check for predictable sequences of characters, such as those in social security numbers, e-mail addresses, telephone numbers, postal codes, and so on.
User-defined
CustomValidator
Checks the user's entry using validation logic that you write yourself. This type of validation allows you to check for values derived at run time.
Source: MSDN

How will you upload a file to IIS in Asp and how will you do the same in ASP.net?
Ans: First of all, we need a HTML server control to allow the user to select the file. This is nothing but the same old . This will give you the textbox and a browse button. Once you have this, the user can select any file from their computer (or even from a network). Then, in the Server side, we need the following line to save the file to the Web Server. myFile.PostedFile.SaveAs ("DestinationPath")
Note: The Form should have the following ENC Type
Source: ASP Alliance
What is Attribute Programming? What are attributes? Where are they used?
Ans: Attributes are a mechanism for adding metadata, such as compiler instructions and other data about your data, methods, and classes, to the program itself. Attributes are inserted into the metadata and are visible through ILDasm and other metadata-reading tools. Attributes can be used to identify or use the data at runtime execution using .NET Reflection.
Source: OnDotNet.com
What is the difference between DataReader & DataSet?
Ans: DataReader is connected, read only forward only record set.
Dataset is in memory database that can store multiple tables, relations and constraints; moreover dataset is disconnected and is not aware of the data source.
What is the difference between server side and client side code?
Ans: Server code is executed on the web server where as the client code is executed on the browser machine.
Why would you use “EnableViewState” property? What are the disadvantages?
Ans: EnableViewState allows me to retain the values of the controls properties across the requests in the same session. It hampers the performance of the application.
What is the difference between Server.Transfer and Response.Redirect?
Ans: The Transfer method allows you to transfer from inside one ASP page to another ASP page. All of the state information that has been created for the first (calling) ASP page will be transferred to the second (called) ASP page. This transferred information includes all objects and variables that have been given a value in an Application or Session scope, and all items in the Request collections. For example, the second ASP page will have the same SessionID as the first ASP page. When the second (called) ASP page completes its tasks, you do not return to the first (calling) ASP page. All these happen on the server side browser is not aware of this.
The redirect message issue HTTP 304 to the browser and causes browser to got the specified page. Hence there is round trip between client and server. Unlike transfer , redirect doesn’t pass context information to the called page.
What is the difference between Application_start and Session_start?
Ans: Application_start gets fired when an application receive the very first request.
Session_start gets fired for each of the user session.
What is inheritance and when would you use inheritance?
Ans: The concept of child class inheriting the behavior of the parent is called inheritance.
If there are many classes in an application that have some part of their behavior common among all , inheritance would be used.
What is the order of events in a web form?
Ans: Init
Load
Cached post back events
Prerender
Unload
Can you edit Data in repeater control?
Ans: No
Which template you must provide to display data in a repeater control?
Ans: Item Template
How can you provide an alternating color scheme in a DataGrid?
Ans: Use ALTERNATINGITEMSTYLE and ITEMSTYLE, attributes or Templates

Is it possible to bind a data to TextBox?
Ans: Yes
What method I should call to bind data to control?
Ans: BindData()
How can I kill a user session?
Ans: Call session.abandon.
Which is the common property among all the validation controls?
Ans: ControlToValidate
How do you bind a data grid column manually?
Ans: Use BoundColumn tag.
Web services can only be written in .NET , true or false?
Ans: False
What does WSDL, UDDI stands for?
Ans: Web Service Description Language.Universal Description Discovery and Integration
How can you make a property read only?(C#)
Ans: Use key word ReadOnly
Which validation control is used to match values in two controls?
Ans: Compare Validation control.
To test a Web Service I must create either web application or windows application. True or false?
Ans: False
How many classes can a single .NET assembly contains?
Ans: Any number
What are the data types available in JavaScript?
Ans: Object is the only datatype available.
Is it possible to share session information among ASP and ASPX page?
Ans: No, it is not possible as both of these are running under different processes.
What are the caching techniques available?
Ans: Page cahahing.
Fragment Caching
And DataCaching
What are the different types of authentication modes available?
Ans: Window.
Form.
Passport.
None.
Explain the steps involved to populate dataset with data?
Ans: Open connection
Initialize Adapter passing SQL and connection as parameter
Initialize Dataset
Call Fill method of the adapter passes dataset as the parameter
Close connection.
Can I have data from two different sources into a single dataset?
Ans: Yes, it is possible.
Is it possible load XML into a Data Reader?
Ans: No.
Is it possible to have tables in the dataset that are not bound to any data source?
Ans: Yes, we can create table object in code and add it to the dataset.
Why do you deploy an assembly into GAC?
Ans: To allow other application to access the shared assembly.

Asp.Net Interview Questions1

Interview Questions ASP.NET

1. 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.
2. What’s the difference between Response.Write() andResponse.Output.Write()?
Ans:The latter one allows you to write formattedoutput.
3. What methods are fired during the page load?
Ans: 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.
4. Where does the Web page belong in the .NET Framework class hierarchy?Ans:System.Web.UI.Page
5. Where do you store the information about the user’s locale?
Ans:System.Web.UI.Page.Culture
6. What’s the difference between Codebehind="MyCode.aspx.cs" andSrc="MyCode.aspx.cs"? Ans:CodeBehind is relevant to Visual Studio.NET only.
7. What’s a bubbled event?
Ans:When you have a complex control, like DataGrid, writing an event processing routine for each object (cell, button, row, etc.) is quite tedious. The controls can bubble up their eventhandlers, allowing the main DataGrid event handler to take care of its constituents.
8. Suppose you want a certain ASP.NET function executed on MouseOver overa certain button. Where do you add an event handler?
Ans:It’s the Attributesproperty, the Add function inside that property. So btnSubmit.Attributes.Add("onMouseOver","someClientCode();")
9. What data type does the RangeValidator control support?
Ans:Integer,String and Date.
10. Explain the differences between Server-side and Client-side code?
Ans:Server-side code runs on the server. Client-side code runs in the clients’ browser.
11. What type of code (server or client) is found in a Code-Behind class?
Ans:Server-side code.
12. Should validation (did the user enter a real date) occur server-side or client-side? Why? Ans:Client-side. This reduces an additional request to the server to validate the users input.
13. What does the "EnableViewState" property do? Why would I want it on or off?
Ans: It enables the viewstate on the page. It allows the page to save the users input on a form.
14. What is the difference between Server.Transfer and Response.Redirect? Why would I choose one over the other?
Ans:Server.Transfer is used to post a form to another page. Response.Redirect is used to redirect the user to another page or site.
15. Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?
Ans: A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
· A DataSet is designed to work without any continuing connection to the original data source.
· Data in a DataSet is bulk-loaded, rather than being loaded on demand.
· There's no concept of cursor types in a DataSet.
· DataSets have no current record pointer You can use For Each loops to move through the data.
· You can store many edits in a DataSet, and write them to the original data source in a single operation.
· Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
16. Can you give an example of what might be best suited to place in the Application_Start and Session_Start subroutines?
Ans:This is where you can set the specific variables for the Application and Session objects.
17. If I’m developing an application that must accommodate multiple security levels though secure login and my ASP.NET web application is spanned across three web-servers (using round-robin load balancing) what would be the best approach to maintain login-in state for the users? Maintain the login state security through a database.
18. Can you explain what inheritance is and an example of when you might use it?
Ans:When you want to inherit (use the functionality of) another class. Base Class Employee. A Manager class could be derived from the Employee base class.
19. Whats an assembly?
Ans:Assemblies are the building blocks of the .NET framework. Overview of assemblies from MSDN
20. Describe the difference between inline and code behind. Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.
21. Explain what a diffgram is, and a good use for one?
Ans:The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.
22. Whats MSIL, and why should my developers need an appreciation of it if at all?
Ans:MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL.
23. Which method do you invoke on the DataAdapter control to load your generated dataset with data? The .Fill() method
24. Can you edit data in the Repeater control? No, it just reads the information from its data source
25. Which template must you provide, in order to display data in a Repeater control? Ans:ItemTemplate
26. How can you provide an alternating color scheme in a Repeater control?
Ans: Use the AlternatingItemTemplate
27. What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control?
Ans:You must set the DataSource property and call the DataBind method.
28. What base class do all Web Forms inherit from?
Ans: The Page class.
29. Name two properties common in every validation control?
Ans:ControlToValidate property and Text property.
30. What tags do you need to add within the asp:datagrid tags to bind columns manually?
Ans:Set AutoGenerateColumns Property to false on the datagrid tag
31. What tag do you use to add a hyperlink column to the DataGrid?
Ans:
32. What is the transport protocol you use to call a Web service?
Ans:SOAP is the preferred protocol.
33. True or False: A Web service can only be written in .NET?
Ans:False
34. What does WSDL stand for?
Ans:(Web Services Description Language)
35. Where on the Internet would you look for Web services?
Ans: (http://www.uddi.org/)
36. 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?
Ans: DataTextField property
37. Which control would you use if you needed to make sure the values in two different controls matched?
Ans: CompareValidator Control
38. True or False: To test a Web service you must create a windows application or Web application to consume this service? False, the webservice comes with a test page and it provides HTTP-GET method to test.
39. How many classes can a single .NET DLL contain?
It can contain many classes.