DOT NET – What is a cookie

Recently I got a message from one of the reader of my site that what exactly is a cookie. So I decided to wire a post dedicated to it .

  1. A cookie is name=value pair like variable which is stored as a file(persistant cookie) and which travels automatically between every request and response.
  2. Cookies are based on domains(website). As long as user is working with current web site cookie will be available.
  3. Cookies are maintained by browser but not by server which means cookies based websites are dependent on client.
  4. Cookies can be created as
    (i) In-memory cookie
    (ii) Persistant Cookie

An In-memory cookie means as long as user is working with app it will be available – also called as Session Cookie.

Persistant cookie means it will be stored in client physical location and available online as well as offline.

Reference : Dilip Kumar Jena ( )

Dot Net 4.0 – Windows Communication Foundation (WCF)

Windows Communication Foundation (WCF)

It is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. There are many other such technologies, including the Component Object Model and Distributed Component Object Model, Remote Method Invocation, Microsoft Message Queuing (MSMQ), and WebSphere MQ.

A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data. A few sample scenarios include:

  • A secure service to process business transactions.
  • A service that supplies current data to others, such as a traffic report or other monitoring service.
  • A chat service that allows two people to communicate or exchange data in real time.
  • A dashboard application that polls one or more services for data and presents it in a logical presentation.
  • Exposing a workflow implemented using Windows Workflow Foundation as a WCF service.
  • A Silverlight application to poll a service for the latest data feeds.

While creating such applications was possible prior to the existence of WCF, WCF makes the development of endpoints easier than ever. In summary, WCF is designed to offer a manageable approach to creating Web services and Web service clients.

We develop WCF as contracts, interface, operations, and data contracts. As the developer we are more focused on the business logic services and need not worry about channel stack. WCF is a unified programming API for any kind of services so we create the service and use configuration information to set up the communication mechanism like HTTP/TCP/MSMQ etc

  • ASMX is IIS and HTTP only – WCF gives you HTTP, NetTcp, MSMQ, IPC – you name it

you can write your service once, and expose it on multiple endpoints

  • self-hosting: you can host your WCF service in a console app, a Winforms app, a WPF app, or let it be handled by IIS/WAS
  • a lot more options like reliable sessions, lot more security options
  • you don’t have to deal with as much in WCF as you do in ASMX – you can concentrate on your business problem, and let the config and attributes handle all the stuff you don’t want to deal with.

ASMX is:

  • easy and simple to write and configure
  • only available in IIS
  • only callable from HTTP

WCF can be:

  • hosted in IIS, a Windows Service, a Winforms application, a console app – you have total freedom
  • used with HTTP (REST and SOAP), TCP/IP, MSMQ and many more protocols

1)Web services can only be invoked by HTTP (traditional webservice with .asmx). While WCF Service or a WCF component can be invoked by any protocol (like http, tcp etc.) and any transport type.

2) web services are not flexible. However, WCF Services are flexible. If you make a new version of the service then you need to just expose a new end. Therefore, services are agile and which is a very practical approach looking at the current business trends.

What Does WCF replace


Rather than requiring different technologies for different communication styles, WCF provides a single unified solution.

1) Component Object Model (COM) It is used to enable interprocess communication and dynamic object creation in a large range of programming languages.

2) Distributed Component Object Model (DCOM) communication among software components distributed across networked computers.

3) MSMQ is essentially a messaging protocol that allows applications running on separate servers/processes to communicate in a failsafe manner.

4) WebSphere MQ is the most popular system for messaging across multiple platforms, including Windows, Linux, OS/2, IBM mainframe and midrange, and Unix. WebSphere MQ is often referred to as “MQ” or “MQ Series”.

5) Web Services Enhancements for .NET (WSE) is a product that enables you to build secure Web services quickly and easily.

6) .NET remoting enables you to build widely distributed applications easily, whether application components are all on one computer or spread out across the entire world


WCF is meant for design and deploying distributed applications under SOA (Service Oriented Architecture) implementation.

WCF is designed in accordance with service oriented architecture principles to support distributed computing where services are consumed by consumers. Clients can consume multiple services and services can be consumed by multiple clients. Services are loosely coupled to each other. Services typically have a WSDL interface (Web Services Description Language) that any WCF client can use to consume the service, irrespective of which platform the service is hosted on. WCF implements many advanced Web services (WS) standards such as WS-AddressingWS-Reliable Messaging and WS-Security. With the release of .NET Framework 4.0, WCF also provides RSS Syndication Services.


A WCF client connects to a WCF service via an Endpoint. Each service exposes its contract via one or more endpoints. An endpoint has an address, which is a URL specifying where the endpoint can be accessed, and binding properties that specify how the data will be transferred.

The mnemonic “ABC” can be used to remember address/binding[disambiguation needed]Contract. Binding specifies what communication protocols are used to access the service, whether security mechanisms are to be used, and the like. WCF includes predefined bindings for most common communication protocols such as SOAP over HTTP, SOAP over TCP, and SOAP over Message Queues, etc. Interaction between WCF endpoint and client is done using a SOAP envelope. SOAP envelopes are in simple XML form that makes WCF platform independent.

When a client wants to access the service via an endpoint, it not only needs to know the contract, but it also has to adhere to the binding specified by the endpoint. Thus, both client and server must have compatible endpoints.

With the release of the .NET Framework 3.5 in November 2007, Microsoft released an encoder that added support for the JSON serialization format to WCF.[1] This allows WCF service endpoints to service requests from AJAX-powered Web pages.


The rental car reservation application provides WCF-based services that can be accessed by various clients.

Unification of Microsoft’s Distributed Computing Technologies

Think about the team of developers implementing the rental car reservation application described earlier. In the world before WCF, this team would need to choose the right distributed technology from the multiple choices originally offered by the .NET Framework. Yet given the diverse requirements of this application, no single technology would fit the bill. Instead, the application would probably use several of these older .NET technologies. For example:

1)  ASMX, also called ASP.NET Web Services, would be an option for communicating with the Java EE-based reservation application and with the partner applications across the Internet. Given that Web services are widely supported today, this would likely be the most direct way to achieve cross-vendor interoperability.

2) .NET Remoting is a natural choice for communication with the call center application, since both are built on the .NET Framework. Remoting is designed expressly for .NET-to-.NET communication, so it would offer the best performance for this situation.

3) Enterprise Services might be used by the rental car reservation application for things such as managing object lifetimes and defining distributed transactions. These functions could be useful in communicating with any of the other applications in this scenario, but Enterprise Services supports only a limited set of communication protocols.

4) Web Services Enhancements (WSE) might be used along with ASMX to communicate with the Java EE-based reservation application and with the partner applications. Because it implements more advanced SOAP-based standards, known collectively as the WS-* specifications, WSE can allow better security and more, as long as all applications involved support compatible versions of these specifications.

5) System.Messaging, which provides a programming interface to Microsoft Message Queuing (MSMQ), could be used to communicate with Windows-based partner applications that weren’t always available. The persistent queuing that MSMQ provides is typically the best solution for intermittently connected applications.

6) System.Net might be used to communicate with partner applications or perhaps in other ways. Using this approach, developers can create applications that use the HTTP-based communication style known as Representational State Transfer (REST).

If it were built on an earlier version of the .NET Framework, the rental car reservation application would need to use more than one of these communication technologies, and maybe even all of them, to meet its requirements. Although this is technically possible, the resulting application would be complex to implement and challenging to maintain. A better solution is needed.

WS – Protocol Support

Security, Reliable Messaging, Transactions, Metadata, Messaging, XML.

Where it can be used

business-to-business (B2B)
business-to-consumer (B2C),
Interoperability with other platforms and technologies
messaging for any kind of communication
and for all the kind of services that were earlier developed using ASMX, WSE, Web Services, MSMQ, and distributed stack. It also helps in creating the distributed application in a very easy manner that earlier would have involved the usage of two or more distributed technology. These custom solution were earlier not possible to develop in either web services or .NET Remoting. WCF facilitates in building these custom solutions. WCF provides a Uniform programming model to creating distributed applications and has been designed to support  Service orientation… many more

Performance Characteristics

In most cases these can be used but might change according to the requirement.

Note : This article is written taking reference from msdn and other standard microsoft sites just to give a clear Idea how this technology works i have compiled into one, also my personal views are written this should not be taken for granted.

Reference : Dilip Kumar Jena ( )

DOT NET 3.0 – Features of C# 3.0

C# 3.0 is the current version, and was released on 19 November 2007 as part of .NET Framework 3.5. It includes new features inspired by functional programming languages such as Haskell and ML, and is driven largely by the introduction of the Language Integrated Query (LINQ) pattern to the Common Language Runtime.[9]

C# 3.0 was unveiled at the 2005 Professional Developers Conference. It is not currently standardized by any standards organisation, though it is expected that it will eventually become an ECMA and then ISO standard, as did its predecessors.

Reference : Dilip Kumar Jena ( )

C Sharp (programming language) and History

C# is an object-oriented programming language developed by Microsoft as part of the .NET initiative and later approved as a standard by ECMA and ISO . Anders Hejlsberg leads development of the C# language, which has a procedural, object-oriented syntax based on C++ and includes influences from aspects of several other programming languages (most notably Delphi and Java) with a particular emphasis on simplification.


During the development of .NET, the class libraries were originally written in a language called Simple Managed C (SMC). In January 1999, Anders Hejlsberg formed a team to build a new language at the time called Cool. By the time the .NET project was publicly announced at the July 2000 Professional Developers Conference (PDC), the language had been renamed C# and the class libraries and ASP.NET runtime had been ported to C#.

C#’s principal designer and lead architect at Microsoft is Anders Hejlsberg, who was previously involved with the design of Visual J++, Borland Delphi, and Turbo Pascal. In interviews and technical papers he has stated that flaws in most major programming languages (e.g. C++, Java, Delphi, and Smalltalk) drove the fundamentals of the Common Language Runtime (CLR), which, in turn, drove the design of the C# programming language itself.

Reference : Dilip Kumar Jena ( )


Many a time when there is a need to go for a navigation bar we simply remember javascript and write a functionality based on mouse onhouver property, we achieve the functionality but sometimes when javascript is disabled on clients computer then what the function never fires but in CSS we have functionality called hover will always run independent of javascript and writing is also very simple here is example how we can achieve it.

Step 1: Create an html file copy and paste the code below.



<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />

<title>Strip Menu Model</title>

<style type=”text/css”>

.stripboxmenu {padding: 0; width: 100%; /* width of the menu strip, 100% will extend to the full resolution of the screen */

border-top: 5px solid #000033; /*specify the color strip width,color */

background: transparent;


.stripboxmenu ul {margin:0;

margin-left: 80px; /*space between first menu item and left edge*/

padding: 0; /*Spacing between the strip and menu boxes*/

list-style: none;


.stripboxmenu li {display: inline;

margin: 2 2px 2 2;

padding: 0;



.stripboxmenu a {

float: left;

display: block;

font: bold 12px Arial; /* Specify the font attributes like font style, boldness */

color: black; /* specify the color of the font */

text-decoration: none; /* remove the default underline of the anchor tag */

margin: 2 2px 2 2; /*Margin between each menu item, you can increase the spacing between the menus by adjusting the attributes*/

padding: 7px 15px 7px 15px; /*with this we can increase the width of the menu item (blue background)*/

background-color: lightblue; /*menu color*/

border-bottom: 9px solid white;


.stripboxmenu a:hover{

background-color: #f98a10; /*Mouseover color*/

padding-top: 20px; /*increase the height of the menu on mouseover using padding attribute */

border-bottom-color: #f98a10;

color: white;


/*Specify the style for current tab*/

.stripboxmenu .current a{

background-color: #000000;

padding-top: 12px;

border-bottom-color: #000000;

color: white;







<li><a href=”#” title=”home”>Home</a></li>

<li><a href=”#” title=”what we do”>What We Do</a></li>

<li><a href=”#” title=”services”>Services</a></li>

<li><a href=”#” title=”clients”>Clients</a></li>

<li><a href=”#” title=”contact us”>Contact Us</a></li>



<br style=”clear: both;” />



Step 2: now run the file in any browser it will look like this

As the html is rendered as li and anchor link inside it we can have many li inside another li to have sub sub menus.

Reference : Dilip Kumar Jena ( )

Dot Net – How to upload excel sheet into databse using Dataset in ASP.NET

I thought of writing this blog post because there can a number of occasion where in you might need to upload something from word file or excel sheet or it can be any kind of  file need to be inserted into the database what we can do many things.

But probably what I feel good and follow most of the time is doing this way so that we can preserve the statements for future reference what we have actually used and where it is going to exactly affect.

Step 1: Create  a website and then add default page on to it.

Step 2: Write the following code in Page_Load(object sender, EventArgs e) function

DataSet ds = new DataSet();

OleDbConnection myCon = new OleDbConnection(@”Provider=Microsoft.Jet.OLEDB.4.0;Data Source=folderpath\sheet.xls;Extended Properties=Excel 8.0;”);

OleDbCommand myComm = new OleDbCommand(“select * from [sheet1$] where State<>””, myCon);

OleDbDataAdapter da = new OleDbDataAdapter(myComm);


for (int i = 0; i < ds.Tables[0].Rows.Count;i++ )


Response.Write(“insert into dbo.Temp2 values(‘” + ds.Tables[0].Rows[i][0].ToString() + “‘,'” + ds.Tables[0].Rows[i][1].ToString() + “‘,'” + ds.Tables[0].Rows[i][2].ToString() + “‘,'” + ds.Tables[0].Rows[i][3].ToString() + “‘)<br />”);



Step 3: Create a table in SQL Server names Temp2 where in u want insert the excel sheet into.

NOTE: The table name can be any name  you like its just an example never take it as standard, its for learing.

create table Temp2(Id varchar(10),country varchar(100),natAnimal varchar(50),lang varchar(50))

Step 4: Create or if u have  excel sheet just make sure that that contains header for each column it will be easy to understand


State Country Animal Language
1 Australia Kangroo English
2 India Peacock Hindi
3 USA American Biston English

This is a sample excel sheet name it as sheet and inside as Sheet1 it will be applied by default so just hit the save button.

So all set!!!

now save the excel sheet in the folder of your website and run the web site the expected Output will be something like this will appear in your broswer

insert into dbo.Temp2 values(‘1′,’Australia’,’Kangroo’,’English’)

insert into dbo.Temp2 values(‘2′,’India’,’Peacock ‘,’Hindi’)

insert into dbo.Temp2 values(‘3′,’USA’,’American Biston’,’English’)

then copy it and paste in ssms (SQL server Query Editor and hit F5 to execute) Finally records are inserted into the database.

There can be many more ways I am sure but this is also handy when you have production and development section seperate.

Reference : Dilip Kumar Jena ( )

DotNet FrameWork – Dot Net Basics Complete Series Reference – Day 0 of 30

30 March 30, 2011 DotNet FrameWork – What actually happens when you add something to an arraylistcollection – How Boxing and unboxing occures in memory – Why only boxed types can be unboxed – Day 30 of 30
29 March 29, 2011 DotNet FrameWork – What is the purpose of XML Namespaces – difference between MetaData and Manifest – What is the use of Internal keyword – Day 29 of 30
28 March 28, 2011 DotNet FrameWork – What is the difference between typeof(foo) and myFoo.GetType() – Day 28 of 30
27 March 27, 2011 DotNet FrameWork – difference between Finalize() and Dispose() – How is the using() pattern useful – What is Program Database (PDB) – Day 27 of 30
26 March 26, 2011 DotNet FrameWork – ASP.NET Web Services vs. .NET Remoting – Security – Asssembly Qualified Name – Day 26 of 30
25 March 25, 2011 DotNet FrameWork – what an Interface is and how it’s different from a Class – difference between XML Web Services using ASMX and .NET Remoting using SOAP – Serialization and Metadata – Day 25 of 30
24 March 24, 2011 DotNet FrameWork – What is PID – What is GAC – Day 24 of 30
23 March 23, 2011 DotNet FrameWork – Managed and Unmanaged Code – multicast delegates – Describe the difference between a Thread and a Process – Day 23 of 30
22 March 22, 2011 DotNet FrameWork – Resource Files – Dispose and Finallize method – encapsulation – What is inline schema, how does it work – Day 22 of 30
21 March 21, 2011 DotNet FrameWork – Check Posting of Page – system.xml Namesapce – Multiple Inheritance – Managed and Unmanaged Code – Globalization and Localization – Day 21 of 30
20 March 20, 2011 DotNet FrameWork – JIT Compilers – Tracing Methods – Debuggind Mode – Day 20 of 30
19 March 19, 2011 DotNet FrameWork – Shared Assemblies – Global Assembly – MSIL – Day 19 of 30
18 March 18, 2011 DotNet FrameWork – What is the difference between structures and enumeration, What is a namespace – Day 18 of 30
17 March 17, 2011 DotNet FrameWork – What Is Boxing And Unboxing,Value Type and Reference Type – Day 17 of 30
16 March 16, 2011 DotNet FrameWork – What is Manifest,Metadata,Delegates,Virtual Keyword,class access modifiers – Day 16 of 30
15 March 15, 2011 DotNet FrameWork – What are the types of assemblies – Day 15 of 30
14 March 14, 2011 DotNet FrameWork – What is an Assembly – Day 14 of 30
13 March 13, 2011 DotNet FrameWork – What is GUID(Globally Unique Identifier) , why we use it and where – Day 13 of 30
12 March 12, 2011 DotNet FrameWork – What are the Main Features of .NET platform – Day 12 of 30
11 March 11, 2011 DotNet FrameWork – Client device independence and basics – Day 11 of 30
10 March 10, 2011 DotNet FrameWork – What is a Formatter – Vendor Neuteality – Interoperability and Web Services – Day 10 of 30
9 March 9, 2011 DotNet FrameWork – Can Private class-level variables be inherited – Protected Internal – Can you write a class without specifying namespace – Day 9 of 30
8 March 8, 2011 DotNet FrameWork– Difference between Overriding and Overloading – Virtual Meaning – Can we Inherit Multiple Interfaces – Difference between Interface and Abstract Class – Day 8 of 30
7 March 7, 2011 DotNet FrameWork– What is DLL Hell –Deploy Assembly – Satellite Assembly – assert() – multiple Inheritance – Day 7 of 30
6 March 6, 2011 DotNet FrameWork– Dot Net Basics – Day 6 of 30
5 March 5, 2011 DotNet FrameWork– What is JIT How it works –Portable Execute – Strong Name – Global Assembly Cache – Difference B/W constants,ReadOnly and Static– Shared and Public Assembly – Types of Authentication –Difference Between Struct and Class – Day 5 of 30
4 March 4, 2011 DotNet FrameWork– difference between Finalize and Dispose (Garbage collection) – Partial Assembly References– Reflection – Basics Day 4 of 30
3 March 3, 2011 DotNet FrameWork–Managed Means–Managed Data– Reflection – Basics Day 3 of 30
2 March 2, 2011 DotNet FrameWork – Basics Day 2 of 30
1 March 1,2011 DotNet FrameWork – Basics Day 1 of 30

Reference : Dilip Kumar Jena ( )