INSTALLING IIS ADDONS (Configuring WCF services in IIS7.0)

By default, IIS 7.0 is not configured for WCF services. Here are the steps to configure IIS 7.0 to run WCF services:


Go to Control Panel –> Programs –> Turn windows feature on or off. Wait for a list to compile here in Microsoft .NET Framework 3.0 or higher section check both “Windows Communication Foundation HTTP Activation” and “Window Communication Foundation Non-HTTP Activation” addons. In section Internet Information Services check all the addons under “Web Management Tools” this is to directly publish WCF from Visual Studio. Press OK and the installation will complete.


At the IIS control panel double click on the MIME Types applet. On the Actions menu, click on the Add menu item. A window pops up, enter the following information:

File name extension: .svc

MIME type: application/octet-stream


Click again on the Default Web Site node on the left side, then double click on the Handler Mappings applet icon on the right side. On the Actions menu, click on the Add Managed Handler. A window pops up, enter the following information:

Request path: *.svc

Type: System.ServiceModel.Activation.HttpHandler

Name: svc-Integrated

IIS is configured for WCF service now we have to deploy a service.

Deploy your service via Visual Studio as Administrator. Right click on Service project file and click to Publish, Now in newly opened dialogue box select Default Application and click the button Create New Web Application name it accordingly and click Open.

Categories: Topics

Difference Between ArrayList and Generic.List C#/VB.Net


  1. Its comes under System.Collections namespace.
  2. Its contains Array of Object.i.e Any objects type we can store in a ArrayList.We can store any no. of objects at runtime.
  3. ArrayList aryList= new ArrayList(); //No Need to specify the object type,can store anything
  4. arList.Add(1);
  5. arList.Add(“Shubhank”);
  6. arList.Add(“False”);
  7. We can store any objects in ArrayList and can retrieve only Objects from ArrayList…
  8. We can say that ArrayList is not Type-Safe.At the Time of inserting recods ,we can store any type of objects,but at the time of fetching we can’t be sure that  Values  which are populate by arList (ArrayList object ) of what type..however.. we have to following code while fetching records/items from Array list
  9. foreach(Object o in arList) { ….}
  10. Because of above  ArrayList is not Fast.Need explicit casting while fetching record from it.


  1.   Its come under System.Collections.Generic.
  2. In List object,we can store only Type of object,which is mentioning while initializing List object
  3. List objList= new we are mentioning string type value i.e in List object only string value can be added,if one has try to insert int type value,then it will through compile time error…
  4. List are Type Safe.
  5. objList.Add(“Shubhank”);
  6. objList.Add(“Upadhyay:);
  7. objList.Add(1);// will give Compile time error
  8. As per declaring of List object we are mentioning string type,So on fetching records from List object we are sure that value are string type.We do not need  to do explicit casting while fetching.
  9. Because of Above Generic.List is Fast.
Categories: Topics

Types of binds in WCF

The binding specifies the set of protocols for communicating with the application. The following table lists the system-provided bindings that represent common options.

Name Purpose
BasicHttpBinding Interoperability with Web services and clients supporting the WS-BasicProfile 1.1 and Basic Security Profile 1.0.
WSHttpBinding Interoperability with Web services and clients that support the WS-* protocols over HTTP.
WSDualHttpBinding Duplex HTTP communication, by which the receiver of an initial message does not reply directly to the initial sender, but may transmit any number of responses over a period of time by using HTTP in conformity with WS-* protocols.
WSFederationBinding HTTP communication, in which access to the resources of a service can be controlled based on credentials issued by an explicitly-identified credential provider.
NetTcpBinding Secure, reliable, high-performance communication between WCF software entities across a network.
NetNamedPipeBinding Secure, reliable, high-performance communication between WCF software entities on the same machine.
NetMsmqBinding Communication between WCF software entities by using MSMQ.
MsmqIntegrationBinding Communication between a WCF software entity and another software entity by using MSMQ.
NetPeerTcpBinding Communication between WCF software entities by using Windows Peer-to-Peer Networking.

The system-provided binding, BasicHttpBinding, incorporates the set of protocols supported by ASP.NET Web services.

Categories: Topics

Types of Constructors

February 28, 2013 Leave a comment

A special method of the class that will be automatically invoked when an instance of the class is created is called as constructor.

Constructors can be classified into 5 types


  1. Default Constructor
  2. Parameterized Constructor
  3. Copy Constructor
  4. Static Constructor
  5. Private Constructor

Default Constructor : A constructor without any parameters is called as default constructor. Drawback of default constructor is every instance of the class will be initialized to same values and it is not possible to initialize each instance of the class to different values.
Parameterized Constructor : A constructor with at least one parameter is called as parameterized constructor. Advantage of parameterized constructor is you can initialize each instance of the class to different values.

Class Leg()
//default Constructor
public Leg()
Name = “Left”;
Num = 2;

//Parametrized Constructor
public Leg(string Name, int Num)
LegName = Name;
LegNum = Num;

static void Main()

Leg L1 = new Leg();  //Default Constructor is called
Leg L2= new Leg(“Left”,2);//Parametrized Constructor is called


Copy Constructor : A parametrized constructor that contains a parameter of same class type is called as copy constructor. Main purpose of copy constructor is to initialize new instance to the values of an existing instance.
class Leg
string A;
int B;
public Leg(string I, int J)
A = I;
B = J;

//Copy Constructor
public Leg(Leg T)
A = T.A;
B = T.B;

public void Print()

Console.WriteLine(“{0}{1}”, A, B);


class CopyConstructor
static void Main()

Leg L = new Leg (“Left”, 2);

//Invoking copy constructor
Leg T1 = new Leg (L);

Static Constructor : You can create a constructor as static and when a constructor is created as static, it will be invoked only once for any number of instances of the class and it is during the creation of first instance of the class or the first reference to a static member in the class. Static constructor is used to initialize static fields of the class and to write the code that needs to be executed only once.

Private Constructor You can also create a constructor as private. When a class contains at least one private constructor, then it is not possible to create an instance for the class. Private constructor is used to restrict the class from being instantiated when it contains every member as static.

  • A class can have any number of constructors.
  • A constructor doesn’t have any return type even void.
  • A static constructor can not be a parameterized constructor.
  • Within a class you can create only one static constructor.

A destructor is a special method of the class that is automatically invoked while an instance of the class is destroyed. Destructor is used to write the code that needs to be executed while an instance is destroyed. To create a destructor, create a method in the class with same name as class preceded with ~ symbol.

Syntax :


Difference between BasicHttpBinding and WsHttpBinding

February 27, 2013 1 comment

Difference between BasicHttpBinding and WsHttpBinding

Microsoft Windows Communication Foundation comes with a set of built-in bindings and each binding is designed to fulfill some specific need. So, if interoperability is our concern and we need to communicate with non-WCF system, then, we should go for basicHttpBinding or wsHttpBinding.But there are many differences between the two bindings.

Following table explains the difference between BasicHttpBinding and WsHttpBinding.

  BasicHttpBinding WsHttpBinding
1 Primarily BasicHttpBinding is designed to exchange SOAP over HTTP(s) only, just like old ASMX or .net web services and supports the WS-I BasicProfile.


WsHttpBinding supports the advanced WS-* specification which includes WS-Addressing and WS-Security etc.
2 It has higher level of interoperability with existing services and clients. Due to more advanced messaging scenarios, it has reduced support for wider range of older clients.
3 BasicHttpBinding is based on SOAP 1.1 specification. WsHttpBinding supports SOAP 1.2 specification.
4 No support for reliable Messaging. Supports for reliable messaging.
5 No support for transactions. It supports atomic and distributed transactions.
6 It has fewer security options. Or we can say, there is no security provided, by default, for BasicHttpBinding. Because WsHttpBinding supports advanced WS-* specification, it has a lot more security options available. For example, It provides message-level security i.e. message is not sent in plain text. Also it supports for WS-Trust and WS-Secure conversation.
7 At transport level, it provides support for confidentiality through SSL. It supports for both Transport as well as Message level security.
8 BasicHttpBinding is a bit faster because security is disabled by default. As it supports advanced security options and its enabled by default, so it’s a bit slower than BasicHttpBinding.

Crosstab queries using PIVOT in SQL Server

February 12, 2013 Leave a comment

A pivot table is a frequently used method of summarizing and displaying especially report data by means of grouping and aggregating values.

T-SQL Pivot Syntax

  [non-pivoted column], -- optional
  [additional non-pivoted columns], -- optional
  [first pivoted column],-- optional
 [additional pivoted columns]
 SELECT query producing sql data for pivot
 -- select pivot columns as dimensions and
 -- value columns as measures from sql tables
) AS TableAlias
 <aggregation function>(column for aggregation or measure column) -- MIN,MAX,SUM,etc
 FOR [<column name containing values for pivot table columns>]
 IN (
 [first pivoted column], ..., [last pivoted column]
) AS PivotTableAlias
ORDER BY clause -- optional

This new feature in SQL Server is PIVOT.  What this allows you to do is to turn query results on their side, so instead of having results listed down like the listing below, you have results listed across.

SalesPerson Product SalesAmount
Bob Pickles $100.00
Sue Oranges $50.00
Bob Pickles $25.00
Bob Oranges $300.00
Sue Oranges $500.00

With a straight query the query results would be listed down, but the ideal solution would be to list the Products across the top for each SalesPerson, such as the following:

SalesPerson Oranges Pickles
Bob $300.00 $125.00
Sue $550.00

To use PIVOT you need to understand the data and how you want the data displayed.  First you have the data rows, such as SalesPerson and the columns, such as the Products and then the values to display for each cross section.  Here is a simple query that allows us to pull the cross-tab results.

SELECT SalesPerson, [Oranges] AS Oranges, [Pickles] AS Pickles
(SELECT SalesPerson, Product, SalesAmount
FROM ProductSales ) ps
SUM (SalesAmount)
FOR Product IN
( [Oranges], [Pickles])
) AS pvt

So how does this work?

There are three pieces that need to be understood in order to construct the query.

  • (1) The SELECT statement
    • SELECT SalesPerson, [Oranges] AS Oranges, [Pickles] AS Pickles
    • This portion of the query selects the three columns for the final result set (SalesPerson, Oranges, Pickles)


  • (2) The query that pulls the raw data to be prepared
    • (SELECT SalesPerson, Product, SalesAmount FROM ProductSales) ps
    • This query pulls all the rows of data that we need to create the cross-tab results.  The (ps) after the query is creating a temporary table of the results that can then be used to satisfy the query for step 1.


  • (3) The PIVOT expression
    • PIVOT (SUM (SalesAmount) FOR Product IN ( [Oranges], [Pickles]) ) AS pvt
    • This query does the actual summarization and puts the results into a temporary table called pvt

Another key thing to notice in here is the use of the square brackets [ ] around the column names in both the SELECT in part (1) and the IN in part (3).  These are key, because the pivot operation is treating the values in these columns as column names and this is how the breaking and grouping is done to display the data.

Categories: Topics Tags:

code to download power point presentation file from one of my website

March 21, 2012 Leave a comment
if (File.Exists(Server.MapPath(file)))
   Response.ContentType = "application/x-mspowerpoint";
   Response.AddHeader("Content-Disposition", "attachment; filename=" + file);

Here Response.ContentType should be set correctly. I have used 
 "application/x-mspowerpoint" for powerpoint. You need to set 
the correct ContentType. For example, for msword you should set 
application/msword, for gif image you should set image/gif, for 
pdf you should set application/pdf etc. 
Categories: Topics