Thursday, February 25, 2010

Difference between outer join and inner join

Inner join:

We use this when we compare two colums from two different table .Based on equality or non equality, we retrieve the rows matched.

Select emp.empid , order.orderid
from emp Innerjoin order
on Emp.empid=order.empid

This example gives all the rows from emp,order tables where the empid's in both the tables are same.

Outer Join:

There are three types of outer joins namely:
Left Outer Join---For retreiving all the columns from the first table irrespective of the column match.
Right Outer Join---For retreiving all the columns from the second table irrespective of the column match
Full Outer Join---For retreiving all the columns from both the tables irrespective of column match.


If we have two tables named stud1,stud2 with the following data

Stud1: id Name stud2: id Name
1 xxx 1 aaa
2 yyy 2 bbb
3 zzz 4 ccc
4 www 6 ddd
When we use Left Outer Join we get the output as:
1 aaa
2 bbb
4 ccc

When we use Right Outer Join we get the output as:
1 aaa
2 bbb
4 ccc

When we use Full Outer Join we get the output as:
1 aaa
2 bbb
4 ccc

JavaScript Object Notation (JSON)

JavaScript Object Notation (JSON)
To allow for a more efficient transfer of data and classes between web applications and
web services, ASP.NET AJAX supports the JavaScript Object Notation (JSON) format. It is
lighter weight than XML (Extensible Markup Language)/SOAP (Simple Object Access
Protocol), and delivers a more consistent experience because of the implementation
differences of XML/SOAP by the various browsers.
JSON is a text-based data-interchange format that represents data as a set of ordered
name/value pairs. As an example, take a look at the following class definition, which
stores a person’s name and age:

public class MyDetails
string FirstName;
string LastName;
int Age;


A two-element array of this object is represented as follows:
{ MyDetails : [ { “FirstName” : “Landon”, “LastName” : “Donovan”, “Age” : “22”}
{ “FirstName” : “John”, “LastName” : “Grieb”, “Age” : “46”}

Monday, February 22, 2010

What is Script Manager in

ScriptManager control is the parent control that needs to be there on every page wherever we are trying to use ASP.NET AJAX controls. ScriptManager control manages client script for AJAX enabled ASP.NET pages. This control enables client script to use the type system extensions and support features for partial page rendering, webservice calls etc.

Can we use Multiple Script Manager on same web-page

No. It is not possible to use multiple ScriptManager control in a web page. In fact, any such requirement never comes in because a single ScriptManager control is enough to handle the objects of a web page.

Difference between Session object and Application object in asp.Net

Session variables are used to store user specific information where as in application variables we can't store user specific information.

Default lifetime of the session variable is 20 mins and based on the requirement we can change it.

Application variables are accessible till the application ends.
sessions allows information to be stored in one page and accessed in another,and it supports any type of object,including your own custom data types.

Application state allows you to store global objects that can be accessed by any client.

The coomon thing b/w session and application is both support the same type of objects,retain information on the server, and uses the same dictionary -based syntax.

Tuesday, February 9, 2010

What is Windows Activation Service (WAS)

Windows Activation Service (WAS), introduced with Windows Vista, is the new process activation mechanism that ships with IIS 7.0. WAS builds on the existing IIS 6.0 process and hosting models, but is much more powerful because it provides support for other protocols besides HTTP, such as TCP and Named Pipes. By hosting the Windows Communication Foundation (WCF) services in WAS, one can take advantage of WAS features such as process recycling, rapid failover protection, and the common configuration system, all of which were previously available only to HTTP-based applications.

Attributes in .Net

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.

Reflection is the process by which a program can read its own metadata. A program is said to reflect on itself, extracting metadata from its assembly and using that metadata either to inform the user or to modify its own behavior.

An attribute is an object that represents data you want to associate with an element in your program. The element to which you attach an attribute is referred to as the target of that attribute.

Using Attributes
Attributes can be placed on most any declaration (though a specific attribute might restrict the types of declarations on which it is valid). Syntactically, an attribute is specified by placing the name of the attribute, enclosed in square brackets, in front of the declaration of the entity to which it applies. For example, a class with the attribute DllImport is declared like this:
[DllImport] public class MyDllimportClass { ... }

Many attributes have parameters, which can be either positional (unnamed) or named.
Any positional parameters must be specified in a certain order and cannot be omitted; named parameters are optional and can be specified in any order. Positional parameters are specified first. For example, these three attributes are equivalent:
[DllImport("user32.dll", SetLastError=false, ExactSpelling=false)]
[DllImport("user32.dll", ExactSpelling=false, SetLastError=false)]

The first parameter, the DLL name, is positional and always comes first; the others are named. In this case, both named parameters default to false, so they can be omitted (refer to the individual attribute's documentation for information on default parameter values).

More than one attribute can be placed on a declaration, either separately or within the same set of brackets:

bool AMethod([In][Out]ref double x);
bool AMethod([Out][In]ref double x);
bool AMethod([In,Out]ref double x);

Creating Custom Attributes

You can create your own custom attributes by defining an attribute class, a class that derives directly or indirectly from System.Attribute (which makes identifying attribute definitions in metadata fast and easy). Suppose you want to tag classes and structs with the name of the programmer who wrote the class or struct. You might define a custom Author attribute class:

using System;
public class Author : Attribute
public Author(string name) { = name; version = 1.0; }
public double version;
string name;

The class name is the attribute's name, Author. It is derived from System.Attribute, so it is a custom attribute class. The constructor's parameters are the custom attribute's positional parameters (in this case, name), and any public read-write fields or properties are named parameters (in this case, version is the only named parameter). Note the use of the AttributeUsage attribute to make the Author attribute valid only on class and struct declarations.

Thursday, February 4, 2010

Difference between Web Services of and Web Services of WCF

The development of web service with ASP.NET relies on defining data and relies on the XmlSerializer to transform data to or from a service.

Key issues with XmlSerializer to serialize .NET types to XML

Only Public fields or Properties of .NET types can be translated into XML.
Only the classes which implement IEnumerable interface.
Classes that implement the IDictionary interface, such as Hash table can not be serialized.
The WCF uses the DataContractAttribute and DataMemeberAttribute to translate .NET FW types in to XML.

public class Item
public string ItemID;
public decimal ItemQuantity;
public decimal ItemPrice;


The DataContractAttribute can be applied to the class or a strcture. DataMemberAttribute can be applied to field or a property and theses fields or properties can be either public or private.

Important difference between DataContractSerializer and XMLSerializer.

A practical benefit of the design of the DataContractSerializer is better performance over XMLserialization.
XMLSerialization does not indicate the which fields or properties of the type are serialized into XML where as DataCotratSerializer Explicitly shows the which fields or properties are serialized into XML.
The DataContractSerializer can translate the HashTable into XML.
Developing Service

To develop a service using ASP.NET we must add the WebService attribute to the class and WebMethodAttribute to any of the class methods.


public class Service : System.Web.Services.WebService
public string Test(string strMsg)
return strMsg;

To develop a service in WCF we will write the following code

public interface ITest
string ShowMessage(string strMsg);
public class Service : ITest
public string ShowMessage(string strMsg)
return strMsg;

The ServiceContractAttribute specifies that a interface defines a WCF service contract, OperationContract Attribute indicates which of the methods of the interface defines the operations of the service contract.

A class that implements the service contract is referred to as a service type in WCF.

Hosting the Service

ASP.NET web services are compiled into a class library assembly and a service file with an extension .asmx will have the code for the service. The service file is copied into the root of the ASP.NET application and Assembly will be copied to the bin directory. The application is accessible using url of the service file.

WCF Service can be hosted within IIS or WindowsActivationService.

Compile the service type into a class library
Copy the service file with an extension .SVC into a virtual directory and assembly into bin sub directory of the virtual directory.
Copy the web.config file into the virtual directory.
Client Development

Clients for the ASP.NET Web services are generated using the command-line tool WSDL.EXE.

WCF uses the ServiceMetadata tool(svcutil.exe) to generate the client for the service.

Message Representation

The Header of the SOAP Message can be customized in ASP.NET Web service.

WCF provides attributes MessageContractAttribute , MessageHeaderAttribute and MessageBodyMemberAttribute to describe the structure of the SOAP Message.

Service Description

Issuing a HTTP GET Request with query WSDL causes ASP.NET to generate WSDL to describe the service. It returns the WSDL as response to the request.

The generated WSDL can be customized by deriving the class of ServiceDescriptionFormatExtension.

Issuing a Request with the query WSDL for the .svc file generates the WSDL. The WSDL that generated by WCF can customized by using ServiceMetadataBehavior class.

Exception Handling

In ASP.NET Web services, Unhandled exceptions are returned to the client as SOAP faults.

In WCF Services, unhandled exceptions are not returned to clients as SOAP faults. A configuration setting is provided to have the unhandled exceptions returned to clients for the purpose of debugging.
Locations of visitors to this page