Monday, April 26, 2010

Working with Javascript on Serverside

Ref: http://www.dotnetcurry.com/ShowArticle.aspx?ID=274&AspxAutoDetectCookieSupport=1

Ref2: http://dotnetslackers.com/articles/aspnet/JavaScript_with_ASP_NET_2_0_Pages_Part1.aspx

Thursday, April 8, 2010

Inversion of Control (IoC) pattern or Dependancy Injection (DI)

Using object-oriented design principles and features such as interface, inheritance, and polymorphism, the IoC pattern enables better software design that facilitates reuse, loose coupling , and easy testing of software components.

Def of DI: Instead creating an new object every time we call the container which will create the object of that class for us.

Injection or Imposing a Dependacy (called an object b or can be a Property, method also) on the De pendant class A through a container or IoC Framework is called DI.

Ref: http://www.dotnetspark.com/kb/266-inversion-control-ioc-and-dependency-injection.aspx

Wednesday, April 7, 2010

Enterprise Library 3.0

Validation Application Block
Ref:http://www.codeproject.com/KB/aspnet/Questpond.aspx

Hosting in IIS 7

Hosting a web application

1. Add user called IIS_IUSRS or go to application pool -> advanced settings -> In Process model we have Identity change it local system.

2. change authentication to None in web.config file.

Hosting a WCF Application

1. Click the Start button, and then click Control Panel.

2. Click Programs, and then click Programs and Features.

3. On the Tasks menu, click Turn Windows features on or off.

4. Find the .NET Framework 3.5 node, select and then expand it.

5. Select the WCF Http Activation Components box and save the setting.

6.change authentication to None in web.config file.

Tuesday, April 6, 2010

Code Access Security (CAS)

CAS is part of .NET security model that determines whether a piece of code is allowed to run and what resources it can use while running. Example CAS will allow an application to read but not to write and delete a file or a resource from a folder..

Boxing and Unboxing

Boxing and unboxing act like bridges between value type and reference types. When we convert value type to a reference type it’s termed as boxing. Unboxing is just vice-versa. When an object box is cast back to its original value type, the value is copied out of the box and into the appropriate storage location.

Below is sample code of boxing and unboxing where integer data type are converted in to object
and then vice versa.

int i = 1;
object obj = i; // boxing
int j = (int) obj; // unboxing


Value types directly contain their data that are either allocated on the stack or allocated in-line in a structure. So value types are actual data.

Reference types store a reference to the value's memory address, and are allocated on the heap. Reference types can be self-describing types, pointer types, or interface types. You can view reference type as pointers to actual data.

Variables that are value types each have their own copy of the data, and therefore operations on one variable do not affect other variables. Variables that are reference types can refer to the same object; therefore, operations on one variable can affect the same object referred to by another variable. All types derive from the System. Object base type.

Garbage collection in .Net

Garbage collection is a CLR feature, which automatically manages memory. Programmers forget
to release the objects while coding ... Laziness (Remember in VB6 where one of the good
practices is to set object to nothing). CLR automatically releases objects when they are no longer
in use and refernced. CLR runs on non-deterministic to see the unused objects and cleans them.
One side effect of this non-deterministic feature is that we cannot assume an object is destroyed
when it goes out of the scope of a function. We should avoid using destructors because before GC
destroys the object it first executes destructor in that case it will have to wait for code to release
the unmanaged resource. This results in additional delays in GC. So it is recommended to
implement IDisposable interface, write cleanup code in Dispose method, and call
GC.SuppressFinalize method. Its like instructing GC not to call your constructor.

Difference between a namespace and assembly

Namespace: It is a Collection of names wherein each name is Unique.
They form the logical boundary for a Group of classes.
Namespace must be specified in Project-Properties.


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

1) It is an Output Unit.
2)It is a unit of Deployment & a unit of versioning.
3)Assemblies contain MSIL code.
4)Assemblies are Self-Describing. [e.g. metadata,manifest]
5)An assembly is the primary building block of a .NET Framework application.
6)It is a collection of functionality that is built, versioned, and deployed as a single implementation unit (as one or more files).
7)All managed types and resources are marked either as accessible only within their implementation unit, or by code outside that unit.

IIS and the Process Model

Ref: http://dotnetslackers.com/articles/iis/ASPNETInternalsIISAndTheProcessModel.aspx

The IIS 5.0 Process Model












The IIS 6.0 Process Model