Thursday, May 3, 2012

Exporting to Word, Excel ,pdf and CSV

In this article, I will explain how to export GridView to Word, Excel, PDF and CSV formats.
Exporting to Word, Excel and CSV can be easily achieved using ASP.Net without any third party tools, but for exporting GridView to PDF I am using iTextSharp which is a free library for exporting html to PDF.
To start with I have a GridView in which I am showing Customers records from the NorthWind Database.
The HTML markup of the GridView is as shown below
<asp:GridView ID="GridView1" runat="server"
    AutoGenerateColumns = "false" Font-Names = "Arial"
    Font-Size = "11pt" AlternatingRowStyle-BackColor = "#C2D69B" 
    HeaderStyle-BackColor = "green" AllowPaging ="true"  
    OnPageIndexChanging = "OnPaging" >
   <Columns>
    <asp:BoundField ItemStyle-Width = "150px" DataField = "CustomerID"
    HeaderText = "CustomerID" />
    <asp:BoundField ItemStyle-Width = "150px" DataField = "City"
    HeaderText = "City"/>
    <asp:BoundField ItemStyle-Width = "150px" DataField = "Country"
    HeaderText = "Country"/>
    <asp:BoundField ItemStyle-Width = "150px" DataField = "PostalCode"
    HeaderText = "PostalCode"/>
   Columns>
asp:GridView>
In the figure below the GridView is shown with four buttons
1.     Export To Word
2.     Export To Excel
3.     Export To PDF
4.     Export To CSV


GridView with Sample Data


Export to Microsoft Word Format
C#
protected void btnExportWord_Click(object sender, EventArgs e)
{
    Response.Clear();
    Response.Buffer = true;
    Response.AddHeader("content-disposition",
    "attachment;filename=GridViewExport.doc");
    Response.Charset = "";
    Response.ContentType = "application/vnd.ms-word ";
    StringWriter sw= new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    GridView1.AllowPaging = false;
    GridView1.DataBind();
    GridView1.RenderControl(hw);
    Response.Output.Write(sw.ToString());
    Response.Flush();
    Response.End();
}
VB.Net
Protected Sub btnExportWord_Click(ByVal sender As Object,
    ByVal e As EventArgs)
        Response.Clear()
        Response.Buffer = True
        Response.AddHeader("content-disposition",
        "attachment;filename=GridViewExport.doc")
        Response.Charset = ""
        Response.ContentType = "application/vnd.ms-word "
        Dim sw As New StringWriter()
        Dim hw As New HtmlTextWriter(sw)
        GridView1.AllowPaging = False
        GridView1.DataBind()
        GridView1.RenderControl(hw)
        Response.Output.Write(sw.ToString())
        Response.Flush()
        Response.End()
    End Sub
The above function renders the GridView contents as Microsoft Word format. You will notice I have disabled paging before exporting, so that all the pages are exported.
The Output Exported File


GridView data exported to Word Document


Export to Microsoft Excel Format
For exporting the document to Excel if you do it directly as done in case of word the row background color is applied throughout to all the columns in the Excel Sheet hence in order to avoid it. I have done a workaround below.
First I am changing the background color of each row back to white.
Then I am applying the background color to each individual cell rather than the whole row. Thus when you export now you will notice that the formatting is applied only to the GridView cells and not all
Also I am applying textmode style class to all cells and then adding the style CSS class to the GridView before rendering it, this ensures that all the contents of GridView are rendered as text.

protected void btnExportExcel_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=GridViewExport.xls");
Response.Charset = "";
Response.ContentType = "application/vnd.ms-excel";
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
GridView1.AllowPaging = false;
GridView1.DataBind();
//Change the Header Row back to white color
GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF");
//Apply style to Individual Cells
GridView1.HeaderRow.Cells[0].Style.Add("background-color", "green");
GridView1.HeaderRow.Cells[1].Style.Add("background-color", "green");
GridView1.HeaderRow.Cells[2].Style.Add("background-color", "green");
GridView1.HeaderRow.Cells[3].Style.Add("background-color", "green");  
for (int i = 0; i < GridView1.Rows.Count;i++ )
{
    GridViewRow row = GridView1.Rows[i];
    //Change Color back to white
    row.BackColor = System.Drawing.Color.White;
    //Apply text style to each Row
    row.Attributes.Add("class", "textmode");
    //Apply style to Individual Cells of Alternating Row
    if (i % 2 != 0)
    {
        row.Cells[0].Style.Add("background-color", "#C2D69B");
        row.Cells[1].Style.Add("background-color", "#C2D69B");
        row.Cells[2].Style.Add("background-color", "#C2D69B");
        row.Cells[3].Style.Add("background-color", "#C2D69B");  
    }
}
GridView1.RenderControl(hw);
//style to format numbers to string
string style = @"";
Response.Write(style);
Response.Output.Write(sw.ToString());
Response.Flush();
Response.End();
}
VB.Net
Protected Sub btnExportExcel_Click(ByVal sender As Object,
ByVal e As EventArgs)
  Response.Clear()
  Response.Buffer = True
  Response.AddHeader("content-disposition",
  "attachment;filename=GridViewExport.xls")
  Response.Charset = ""
  Response.ContentType = "application/vnd.ms-excel"
 
  Dim sw As New StringWriter()
  Dim hw As New HtmlTextWriter(sw)
  GridView1.AllowPaging = False
  GridView1.DataBind()
  'Change the Header Row back to white color
  GridView1.HeaderRow.Style.Add("background-color", "#FFFFFF")
  'Apply style to Individual Cells
  GridView1.HeaderRow.Cells(0).Style.Add("background-color", "green")
  GridView1.HeaderRow.Cells(1).Style.Add("background-color", "green")
  GridView1.HeaderRow.Cells(2).Style.Add("background-color", "green")
  GridView1.HeaderRow.Cells(3).Style.Add("background-color", "green")
  For i As Integer = 0 To GridView1.Rows.Count - 1
   Dim row As GridViewRow = GridView1.Rows(i)
   'Change Color back to white
   row.BackColor = System.Drawing.Color.White
   'Apply text style to each Row
   row.Attributes.Add("class", "textmode")
   'Apply style to Individual Cells of Alternating Row
   If i Mod 2 <> 0 Then
    row.Cells(0).Style.Add("background-color", "#C2D69B")
    row.Cells(1).Style.Add("background-color", "#C2D69B")
    row.Cells(2).Style.Add("background-color", "#C2D69B")
    row.Cells(3).Style.Add("background-color", "#C2D69B")
   End If
  Next
  GridView1.RenderControl(hw)
  'style to format numbers to string
  Dim style As String = ""
  Response.Write(style)
  Response.Output.Write(sw.ToString())
  Response.Flush()
  Response.End()
End Sub
The Output Exported File


GridView data exported to Excel Document


Export to Portable Document Format
For exporting the GridView to PDF I am using the iTextSharp Library. You will need to Add Reference for the iTextSharp Library in your Website.
Then import the following Namespaces
C#
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html;
using iTextSharp.text.html.simpleparser;
VB.Net
Imports iTextSharp.text
Imports iTextSharp.text.pdf
Imports iTextSharp.text.html
Imports iTextSharp.text.html.simpleparser
By default the iTextSharp Library does not support background color of table cells or table rows
Hence when you render it as PDF your GridView is rendered without any formatting.
Recently I read an article on hamang.net where the author has provided the snippet to modify the iTextSharp so that it exports the HTML with background color.
For this tutorial, I have already modified the iTextSharp Library DLL so that the GridView is rendered with all the background color used. You can refer the code for exporting GridView to PDF below
              
C#
protected void btnExportPDF_Click(object sender, EventArgs e)
{
    Response.ContentType = "application/pdf";
    Response.AddHeader("content-disposition",
     "attachment;filename=GridViewExport.pdf");
    Response.Cache.SetCacheability(HttpCacheability.NoCache);
    StringWriter sw = new StringWriter();
    HtmlTextWriter hw = new HtmlTextWriter(sw);
    GridView1.AllowPaging = false;
    GridView1.DataBind();
    GridView1.RenderControl(hw);
    StringReader sr = new StringReader(sw.ToString());
    Document pdfDoc = new Document(PageSize.A4, 10f,10f,10f,0f);
    HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
    PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
    pdfDoc.Open();
    htmlparser.Parse(sr);
    pdfDoc.Close();
    Response.Write(pdfDoc);
    Response.End(); 
}
VB.Net
Protected Sub btnExportPDF_Click(ByVal sender As Object,
ByVal e As EventArgs)
 Response.ContentType = "application/pdf"
 Response.AddHeader("content-disposition",
 "attachment;filename=GridViewExport.pdf")
 Response.Cache.SetCacheability(HttpCacheability.NoCache)
 Dim sw As New StringWriter()
 Dim hw As New HtmlTextWriter(sw)
 GridView1.AllowPaging = False
 GridView1.DataBind()
 GridView1.RenderControl(hw)
 Dim sr As New StringReader(sw.ToString())
 Dim pdfDoc As New Document(PageSize.A4, 10.0F, 10.0F, 10.0F, 0.0F)
 Dim htmlparser As New HTMLWorker(pdfDoc)
 PdfWriter.GetInstance(pdfDoc, Response.OutputStream)
 pdfDoc.Open()
 htmlparser.Parse(sr)
 pdfDoc.Close()
 Response.Write(pdfDoc)
 Response.End()
End Sub
The Output Exported File


GridView data exported to PDF Document


Export to Text/CSV
Finally comes exporting GridView to CSV or Text File delimited by a separator like comma.
To export the GridView as CSV, I am running a two for loops. While looping through the GridView columns and appending comma after each column and while looping through rows appending new line character. Refer the code below.
C#
protected void btnExportCSV_Click(object sender, EventArgs e)
{
    Response.Clear();
    Response.Buffer = true;
    Response.AddHeader("content-disposition",
     "attachment;filename=GridViewExport.csv");
    Response.Charset = "";
    Response.ContentType = "application/text";
    GridView1.AllowPaging = false;
    GridView1.DataBind();
    StringBuilder sb = new StringBuilder();
    for (int k = 0; k < GridView1.Columns.Count; k++)
    {
        //add separator
        sb.Append(GridView1.Columns[k].HeaderText + ',');
    }
    //append new line
    sb.Append("\r\n");
    for (int i = 0; i < GridView1.Rows.Count; i++)
    {
        for (int k = 0; k < GridView1.Columns.Count; k++)
        {
            //add separator
            sb.Append(GridView1.Rows[i].Cells[k].Text + ',');
        }
        //append new line
        sb.Append("\r\n");
    }
    Response.Output.Write(sb.ToString());
    Response.Flush();
    Response.End();
}
      
VB.Net
Protected Sub btnExportCSV_Click(ByVal sender As Object,
ByVal e As EventArgs)
 Response.Clear()
 Response.Buffer = True
 Response.AddHeader("content-disposition",
 "attachment;filename=GridViewExport.csv")
 Response.Charset = ""
 Response.ContentType = "application/text"
 GridView1.AllowPaging = False
 GridView1.DataBind()
 Dim sb As New StringBuilder()
 For k As Integer = 0 To GridView1.Columns.Count - 1
  'add separator
  sb.Append(GridView1.Columns(k).HeaderText + ","c)
 Next
 'append new line
 sb.Append(vbCr & vbLf)
 For i As Integer = 0 To GridView1.Rows.Count - 1
  For k As Integer = 0 To GridView1.Columns.Count - 1
   'add separator
   sb.Append(GridView1.Rows(i).Cells(k).Text + ","c)
  Next
  'append new line
  sb.Append(vbCr & vbLf)
 Next
 Response.Output.Write(sb.ToString())
 Response.Flush()
 Response.End()
End Sub
The Output Exported File


GridView data exported to CSV File


When you run the application first time and click export you might receive the following error


Error encountered when you click export


To avoid the error you will need to add this event which ensures that the GridView is Rendered before exporting.
  
C#
public override void VerifyRenderingInServerForm(Control control)
{
    /* Verifies that the control is rendered */
}
VB.Net
Public Overloads Overrides Sub VerifyRenderingInServerForm
(ByVal control As Control)
    ' Verifies that the control is rendered
End Sub


Monday, April 9, 2012

Currenct Convertor( Number to Word) Asp.Net (C#)

1) Indian Ruppess

public string NumberToWord(Int32 number)
{

if (number == 0) return "Zero";

//if (number == -2147483648) return "Minus Two Hundred and Fourteen Crore Seventy Four Lakh Eighty Three Thousand Six Hundred and Forty Eight";

int[] num = new int[4];
int first = 0;
int u, h, t;

System.Text.StringBuilder sb = new System.Text.StringBuilder();

if (number < 0)
{

sb.Append("Minus ");
number = -number;
}

string[] words0 = { "", "One ", "Two ", "Three ", "Four ", "Five ", "Six ", "Seven ", "Eight ", "Nine " };

string[] words = { "Ten ", "Eleven ", "Twelve ", "Thirteen ", "Fourteen ", "Fifteen ", "Sixteen ", "Seventeen ", "Eighteen ", "Nineteen " };

string[] words2 = { "Twenty ", "Thirty ", "Forty ", "Fifty ", "Sixty ", "Seventy ", "Eighty ", "Ninety " };

string[] words3 = { "Thousand ", "Lakh ", "Crore " };
// { "", "thousand", "million", "billion", "trillion", "quadrillion", "quintillion" };


num[0] = number % 1000; // units

num[1] = number / 1000;

num[2] = number / 100000;

num[1] = num[1] - 100 * num[2];// thousands

num[3] = number / 10000000; // crores

num[2] = num[2] - 100 * num[3]; // lakhs



for (int i = 3; i > 0; i--)
{
if (num[i] != 0)
{
first = i;
break;
}
}

for (int i = first; i >= 0; i--)
{

if (num[i] == 0) continue;

u = num[i] % 10; // ones

t = num[i] / 10;

h = num[i] / 100; // hundreds

t = t - 10 * h; // tens

if (h > 0) sb.Append(words0[h] + "Hundred ");

if (u > 0 || t > 0)
{

if (h > 0 || i == 0) sb.Append("and ");

if (t == 0)

sb.Append(words0[u]);

else if (t == 1)

sb.Append(words[u]);

else

sb.Append(words2[t - 2] + words0[u]);

}

if (i != 0) sb.Append(words3[i - 1]);

}

return sb.ToString().TrimEnd();

}


2) Dollar and Euro

public string NumberToWords(string rawnumber)
{
int inputNum = 0;
int dig1, dig2, dig3, level = 0, lasttwo, threeDigits;
string dollars, cents;
try
{
string[] Splits = new string[2];
Splits = rawnumber.Split('.'); //notice that it is ' and not "
inputNum = Convert.ToInt32(Splits[0]);
dollars = "";
cents = Splits[1];
if (cents.Length == 1)
{
cents += "0"; // 12.5 is twelve and 50/100, not twelve and 5/100
}
}
catch
{
cents = "00";
inputNum = Convert.ToInt32(rawnumber);
dollars = "";
}

string x = "";

//they had zero for ones and tens but that gave ninety zero for 90
string[] ones = { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" };
string[] tens = { "", "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
string[] thou = { "", "Thousand", "Million", "Billion", "Trillion", "Quadrillion", "Quintillion" };

bool isNegative = false;
if (inputNum < 0)
{
isNegative = true;
inputNum *= -1;
}
if (inputNum == 0)
{
//return "zero and " + cents + "/100";
return "zero";
}

string s = inputNum.ToString();

while (s.Length > 0)
{
//Get the three rightmost characters
x = (s.Length < 3) ? s : s.Substring(s.Length - 3, 3);

// Separate the three digits
threeDigits = int.Parse(x);
lasttwo = threeDigits % 100;
dig1 = threeDigits / 100;
dig2 = lasttwo / 10;
dig3 = (threeDigits % 10);

// append a "thousand" where appropriate
if (level > 0 && dig1 + dig2 + dig3 > 0)
{
dollars = thou[level] + " " + dollars;
dollars = dollars.Trim();
}

// check that the last two digits is not a zero
if (lasttwo > 0)
{
if (lasttwo < 20)
{
// if less than 20, use "ones" only
dollars = ones[lasttwo] + " " + dollars;
}
else
{
// otherwise, use both "tens" and "ones" array
dollars = tens[dig2] + " " + ones[dig3] + " " + dollars;
}
if (s.Length < 3)
{
if (isNegative) { dollars = "negative " + dollars; }
//return dollars + " and " + cents + "/100";
return dollars ;
}
}

// if a hundreds part is there, translate it
if (dig1 > 0)
{
dollars = ones[dig1] + " hundred " + dollars;
s = (s.Length - 3) > 0 ? s.Substring(0, s.Length - 3) : "";
level++;
}
else
{
if (s.Length > 3)
{
s = s.Substring(0, s.Length - 3);
level++;
}
}
}

if (isNegative) { dollars = "negative " + dollars; }
//return dollars + " and " + cents + "/100";
return dollars ;

}



Using Stored Procedure(Sql Server)


Create Procedure NumberToWord
@Number AS BIGINT
AS
BEGIN
DECLARE @Digits INT
SET @Digits = @Number
IF (LEN(@Digits) > 4)
BEGIN
RAISERROR ('PLEASE ENTER WITH IN 4 DIGIT NUMBERS',12,-1)
END
ELSE IF (LEN(@Digits) <= 4)
BEGIN
DECLARE @NumWords TABLE(Number INT, Ones VARCHAR(15), Tens VARCHAR(15), Hundreds VARCHAR(15), Thousands VARCHAR(15))
INSERT INTO @NumWords
SELECT 0,'','','','' UNION ALL
SELECT 1,'ONE','TEN','ONE HUNDRED','ONE THOUSAND' UNION ALL
SELECT 2,'TWO','TWENTY','TWO HUNDRED','TWO THOUSAND' UNION ALL
SELECT 3,'THREE','THIRTY','THREE HUNDRED','THREE THOUSAND' UNION ALL
SELECT 4,'FOUR','FORTY','FOUR HUNDRED','FOUR THOUSAND' UNION ALL
SELECT 5,'FIVE','FIFTY','FIVE HUNDRED','FIVE THOUSAND' UNION ALL
SELECT 6,'SIX','SIXTY','SIX HUNDRED','SIX THOUSAND' UNION ALL
SELECT 7,'SEVEN','SEVENTY','SEVEN HUNDRED','SEVEN THOUSAND' UNION ALL
SELECT 8,'EIGHT','EIGHTY','EIGHT HUNDRED','EIGHT THOUSAND' UNION ALL
SELECT 9,'NINE','NINETY','NINE HUNDRED','NINETHOUSAND' UNION ALL
SELECT 10,'NINETEEN','','','' UNION ALL
SELECT 11,'ELEVEN','','','' UNION ALL
SELECT 12,'TWELVE','','','' UNION ALL
SELECT 13,'THIRTEEN','','','' UNION ALL
SELECT 14,'FOURTEEN','','','' UNION ALL
SELECT 15,'FIFTEEN','','','' UNION ALL
SELECT 16,'SIXTEEN','','','' UNION ALL
SELECT 17,'SEVENTEEN','','','' UNION ALL
SELECT 18,'EIGHTEEN','','','' UNION ALL
SELECT 19,'NINETEEN','','',''
SELECT RTRIM(MAX(CASE WHEN NUMBER = SUBSTRING(REVERSE(@Digits),4,1) THEN THOUSANDS ELSE '' END)) --FROM @NumWords
+SPACE(2)+ LTRIM(MAX(CASE WHEN NUMBER = SUBSTRING(REVERSE(@Digits),3,1) THEN HUNDREDS ELSE '' END) )
+SPACE(2)+ MAX(CASE WHEN RIGHT(@Digits,2) NOT BETWEEN 11 AND 19 AND NUMBER = SUBSTRING(REVERSE(@Digits),2,1) THEN TENS ELSE '' END)
+SPACE(2)+ MAX(CASE WHEN RIGHT(@Digits,2) NOT BETWEEN 11 AND 19 AND NUMBER = RIGHT(@Digits,1) THEN ONES
WHEN RIGHT(@Digits,2) BETWEEN 11 AND 19 AND NUMBER = RIGHT(@Digits,2) THEN ONES ELSE '' END)
As "Number to Words"
FROM @NUMWORDS
END
END
--EXEC NumberToWord 2010

Friday, November 25, 2011

Displaying multiple records in one row

I have a table with values as follows:

SQL> SELECT deptno, ename FROM emp ORDER BY deptno, ename;

DEPTNO ENAME

------ ----------

10 CLARK

10 KING

10 MILLER

20 ADAMS

20 FORD

20 JONES

20 SCOTT

20 SMITH

30 ALLEN

30 BLAKE

30 JAMES

30 MARTIN

30 TURNER

30 WARD

14 rows selected.

but I need them in the following less convenient format:

DEPTNO ENAME

------ -----------------------------------------

10 CLARK, KING, MILLER

20 ADAMS, FORD, JONES, SCOTT, SMITH

30 ALLEN, BLAKE, JAMES, MARTIN, TURNER, WARD

The following example illustrates the technique using the SCOTT demo table "emp":2

SELECT deptno

, LTRIM(SYS_CONNECT_BY_PATH(ename,','))

FROM ( SELECT deptno, ename

, ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS seq

FROM emp )

WHERE connect_by_isleaf = 1

CONNECT BY seq = PRIOR seq +1 AND deptno = PRIOR deptno

START WITH seq = 1;

DEPTNO CONCATENATED

---------- --------------------------------------------------

10 CLARK,KING,MILLER

20 ADAMS,FORD,JONES,SCOTT,SMITH

30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

3 rows selected.

Another approach involves harnessing the dark power of XML:3

SELECT deptno

, RTRIM

( xmlagg (xmlelement (c, ename || ',') order by ename).extract ('//text()')

, ',' ) AS concatenated

FROM emp

GROUP BY deptno;

DEPTNO CONCATENATED

---------- ---------------------------------------------------------------

10 CLARK,KING,MILLER

20 ADAMS,FORD,JONES,SCOTT,SMITH

30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD

3 rows selected.

Friday, November 11, 2011

Differnce between .NET FrameWork

.NET FrameWork 2. 0 Features:
Generics
Anonymous methods
Partial class
Nullable type
The new API gives a fine grain control on the behavior of the runtime with regards to multithreading, memory allocation, assembly loading and more
Full 64-bit support for both the x64 and the IA64 hardware platforms
New personalization features for ASP.NET, such as support for themes, skins and webparts.
.NET Micro Framework
Data Tables

.NET Framework 3.0 Features:

Also called WinFX,includes a new set of managed code APIs that are an integral part of Windows Vista and Windows Server 2008 operating systems and provides
Windows Communication Foundation (WCF) – formerly called Indigo; a service-oriented messaging system which allows programs to interoperate locally or remotely similar to web services
Windows Presentation Foundation (WPF) - formerly called Avalon; a new user interface subsystem and API based on XML and vector graphics, which uses 3D computer graphics hardware and Direct3D technologies.
Windows Workflow Foundation (WF) allows for building of task automation and integrated transactions using workflows.
Windows CardSpace, formerly called InfoCard; a software component which securely stores a person’s digital identities and provides a unified interface for choosing the identity for a particular transaction, such as logging in to a website

.NET Framework 3.5 Features:

Language Integrated Query (LINQ) for SQL, XML, Dataset, Object
Addin system
p2p base class
Active directory
ASP.NET Ajax
Anonymous types with static type inference
Paging support for ADO.NET
ADO.NET synchronization API to synchronize local caches and server side data stores
Asynchronous network I/O API
Support for HTTP pipelining and syndication feeds.
New System.CodeDom namespace

.NET Framework 4.0 Features:

Common Language Runtime (CLR) – The following sections describe new features in security, parallel computing, performance and diagnostics, dynamic language runtime, and other CLR-related technologies
Base Class Libraries
Networking – Enhancements have been made that affect how integrated Windows authentication is handled by the HttpWebRequest, HttpListener, SmtpClient, SslStream, NegotiateStream, and related classes in the System.Net and related namespaces
Web – The following sections describe new features in ASP.NET core services, Web Forms, Dynamic Data, and Visual Web Developer.
Client – The following sections describe new features in Windows Presentation Foundation (WPF) and Managed Extensibility Framework (MEF).
Data
Communications – Windows Communication Foundation (WCF) provides the new features and enhancements described in the following sections.
Workflow – Windows Workflow Foundation (WF) in .NET Framework 4.0 changes several development paradigms from earlier versions. Workflows are now easier to create, execute, and maintain.