.NET 4.5 Improvements for Cloud and Server Applications

I’ve had multiple meetings recently with customers and press where the topic of .NET development has come up, particularly as it relates to the cloud and server.  They’ve heard about the extensive work we’ve done with Visual Studio 11 to enable the client-side development of Metro style apps for Windows 8 using C#, Visual Basic, C++, and JavaScript, and they’re curious to learn what improvements have been made for server-side development using .NET

From my perspective, .NET is already the richest and most productive way for developers to create server-side applications that run in the cloud and on premises, and to do so with symmetry across both.  With .NET 4 available today on Windows Server and in Windows Azure, developers have in place the languages, libraries, frameworks, and capabilities necessary to create next-generation solutions, whether for the enterprise or for a consumer application.

And things only get better with .NET 4.5. The coming release of .NET is targeted to provide great capabilities for developers working on mobile apps, web apps, and cloud services, while at the same time enabling rapid scalability, fast time to market, and support that spans a gamut of PCs, browsers, and mobile devices. Work in .NET 4.5 has been done at all levels of the stack, from the internals of the Common Language Runtime (CLR), to the Base Class Libraries (BCL), to Entity Framework (EF), to Windows Communication Foundation (WCF), to Windows Workflow Foundation (WF), to ASP.NET. 

Given the aforementioned questions I’ve received about server-side development with .NET 4.5, I thought I’d share some highlights for what’s coming in this very exciting release.


For a broad view of what’s new for web development, I recommend reading What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11. For the purposes of this post, I’ll focus on a few highlights.

In our modern world of connected devices and continuous services, a very important aspect of a web site is being able to provide great results for mobile devices.  ASP.NET in .NET 4.5 enables just that, with mobile support built into ASP.NET MVC 4 that enables optimized experiences to be delivered for tablets and phones.  ASP.NET Web Pages also includes support for Mobile Display Modes, which enable you to create device-specific pages that are rendered conditionally based on the device making the request.

ASP.NET Web Forms has also seen a lot of love in .NET 4.5.  Web Forms now supports model binding, which allows data controls to directly bind query parameters to form fields, query strings, cookies, session state, and view state.  These data controls can also use strongly-typed binding expressions, rather than using the customary dynamic binding methods where type information is only available at run time.  Additional support for HTML5 is included as well, such as support for new HTML5 form type elements like ‘email’, ‘tel’, ‘url’, and ‘search’.

ASP.NET in .NET 4.5 now has support for WebSockets, a protocol that provides bidirectional communication over ports 80 and 443 but still with performance similar to that of TCP, enabling a good alternative to long-polling.  It has much improved support for writing asynchronous code.  It has support for bundling and minification of JavaScript, which results in less data to be served to clients and faster load times for applications.  And it has inherent performance improvements, such as a ~30% reduction in base level memory consumption for an ASP.NET application.

Of course, the improvements go beyond just programming model capabilities and performance.  The code editor in Visual Studio has been enhanced with new ASP.NET Smart Tasks, with IntelliSense improvements, and with refactoring support.

As I’ve discussed previously on this blog, JavaScript support in Visual Studio 11 has also been enhanced significantly, and the code editor in Visual Studio 11 has some very handy HTML5 and CSS3 code editor improvements.  The new Page Inspector tool in Visual Studio 11 also enables developers to better connect the browser on the client with code on the server, letting developers easily map HTML elements to the source that resulted in their rendering.


The ability to query for data is an integral aspect of many web applications and services, and .NET 4.5 delivers some significant updates in the data space, particularly around the Entity Framework.

Entity Framework 5 (included in .NET 4.5) now supports multiple development workflows, catering to whichever methodology the developer prefers.  Some developers prefer to first create their database and then consume that into their application; this is enabled with the “database first” approach.  Others prefer a more “model first” approach, where a designer or an XML editor can be used to define entities in an application domain, highlighting how these relate to each other and to concrete representations which can then be used to generate a database.  Still other developers prefer a more “code first” approach, where they define their model objects using “plain old classes,” never having to open a designer or define a mapping in XML.  With the .NET Framework 4.5, developers don’t have to choose, as all three approaches are supported (with “code first”, Entity Framework now also supports migrations, enabling developers to easily modify and version their database schema without dropping any data).

Entity Framework in .NET 4.5 includes a variety of new features focused on making the developer more productive.  For example, .NET enum types can now be mapped to the underlying Entity Data Model (EDM). Table-valued functions (TVF) are now supported, making it possible to use LINQ queries and Entity SQL against them.  Spatial data is now supported, with two new primitive EDM types called Geometry and Geography, and with their associated .NET types DbGeometry and DbGeography.

The Entity Framework has also seen some significant performance improvements in .NET 4.5.  For example, it now supports automatically compiled LINQ queries.  Queries written with the Entity Framework are manifested as expression trees which need to be translated at run time into SQL queries.  That transformation can take some measurable time, in particular for very complex queries.  .NET 4.5 supports the automatic caching of query compilations, alleviating the need for the developer to do so manually to achieve the same performance benefits.  The impact of these performance improvements when combined with others in the system have resulted in throughput improvements on some queries by as much as 600%.

For more information on what’s new in Entity Framework in .NET 4.5, the Data Developer Center on MSDN is a good place to start.


One of the significant new features to surface in .NET 4.5 is the new Web API framework.  ASP.NET Web API enables developers to build modern HTTP services that can be consumed by a broad range of clients, including browsers and mobile devices.  It supports content negotiation, such that clients and servers can work together to determine the right format for data to be returned.  It supports automatic serialization of data to JSON, XML, and Form URL-encoded data.  It enables easily exposing REST APIs that map incoming requests to business logic using built-in routing and validation support.  It supports query composition, such that the framework can automatically layer on top of IQueryable<T>-returning APIs support for paging and sorting and other capabilities.  It supports testing with mocking frameworks, and much more.

It is also highly productive.  The ASP.NET Web API tutorial has a good example of how easy it is to build a simple API; this API just returns a list of available products, which for the purposes of the example has been hardcoded:

public IEnumerable<Product> GetAllProducts()
    return new List<Product>
        new Product() { Id=1, Name="Gizmo 1", Price=1.99M },
        new Product() { Id=2, Name="Gizmo 2", Price=2.99M },
        new Product() { Id=3, Name="Gizmo 3", Price=3.99M }

This API can then easily be consumed from any client, such as one using JavaScript in a browser.  For more information on ASP.NET Web API, I recommend the ASP.NET Web API site.

Windows Communication Foundation (WCF) has also been significantly enhanced for .NET 4.5, making it much easier to develop robust web services.  As with ASP.NET, one of the major WCF features in .NET 4.5 is support for WebSockets, exposed via the NetHttpBinding and NetHttpsBinding bindings.  UDP support has also been added to WCF in .NET 4.5.

WCF has also been augmented with productivity features.  WCF in .NET 4.5 supports contract-first development, such that you can generate service and data contracts from a WSDL document and then provide the backing implementation.  The configuration files used by WCF have been greatly simplified, such that the defaults used are much more likely to be appropriate for production use and thus don’t need to be specified.

The WCF support in .NET 4.5 also ties in with the greatly overhauled asynchronous story in .NET 4.5, which I’ve previously written about and which I’ll mention again later in this post.  WCF service methods can now be written to return Tasks, and can thus be implemented using the new async and await keywords in C# and Visual Basic.  WCF also now has support for true asynchronous streaming, which can lead to important scalability benefits.

The What’s New in Windows Communication Foundation 4.5 page provides a good overview on the breadth of what’s new.


Windows Workflow Foundation (WF) is a key technology for implementing long-running processes, the kind that often show up in server and cloud workloads.  It includes a programming model, an in-process workflow engine, and a designer, all of which have been improved for .NET 4.5.

Several of the more prominent improvements for WF are visible in this simple screenshot I took after experimenting with some of the features:

This image highlights the state machine workflows that are now possible to create using .NET 4.5.  Further, it shows that C# expressions are now supported in the workflow designer (this is in addition to the support for Visual Basic expressions that were already supported in the previous release).  The designer showcased here has also been improved significantly, with support for new features like search, click-and-drag support to pan around the workflow, an outline view to make it easier to navigate hierarchical workflows, support for multi-select, and more.

These are just some of the improvements available for WF in .NET 4.5.  Others include being able to run different versions of the same workflow side-by-side, better control of how child activities persist in the workflow, and improved debugging support and build-time validation.

For more on what’s new in Windows Workflow in .NET 4.5, I recommend the What's New in Windows Workflow Foundation in .NET 4.5 overview material in the MSDN documentation.


Windows Identity Foundation (WIF) is a set of classes that support implementing claims-based identity, something particularly relevant to web applications and services.  Prior to the .NET Framework 4.5, WIF shipped as a standalone entity, but as of .NET 4.5 its types are integrated into the heart of the Framework.  In fact, some types at the center of .NET’s security model now inherit from WIF types; for example, GenericPrincipal (which has been in .NET since v1) now derives from the WIF type ClaimsIdentity.  This deep integration makes it much easier to use claims.

Other improvements are also available in WIF as part of .NET 4.5.  Session management has been improved for web farms, such that custom code is no longer required.  Developers can simulate any incoming claim types and values at development time using Visual Studio 11 support for WIF.  You can also use Visual Studio support for Windows Azure Access Control Service (ACS) to easily enable application login using Active Directory, Facebook, Windows Live ID, Google, Yahoo!, or any other OpenID provider.

For more information on WIF, the Windows Identity Foundation 4.5 Overview is a good place to get started.


The fewer resources on average a server system uses to process a request, the more requests the system can process concurrently, and the more you can do with less.  One key way server and cloud systems enable this kind of scalability is via asynchrony, such that thread-related resources are only consumed when they’re needed for executing code; while waiting for I/O to complete that will yield the data necessary for a computation to continue, asynchronous solutions allow the system’s threading resources to be used for other means.

As has already been alluded to in discussions of ASP.NET, WCF, and WF, up and down the stack improvements have been made for .NET 4.5 around asynchrony.  Both C# and Visual Basic have been extended with new “async” and “await” keywords that allow developers to write asynchronous code with the same control flow constructs they use in their synchronous code, avoiding the need for complicated, explicit callback mechanisms (F# already had a similar capability in Visual Studio 2010).  Then throughout the Framework, types have been augmented with Task-returning methods that make functionality immediately consumable using the new keywords, and hooks have been added that allow developers to write Task-returning methods and have them hosted by the system in an asynchronous manner.  These improvements make it possible for developers to build asynchronous systems much more productively.

Consider an asynchronous action method written with ASP.NET MVC.  In this method, I want to first download the contents of http://bing.com, and then once that’s completed, I want to download the contents of http://msdn.com.  I also want to report any errors that occur.  Doing this prior to .NET 4.5 would have resulted in a page’s worth of code, with nested callbacks, complicated error handling, and manual management for tracking outstanding operations.  With .NET 4.5, I can instead simply write a straightforward action method like the following:

public async Task<ActionResult> IndexAsync() {
    var client = new HttpClient();
    try {
        ViewBag.BingContent = await client.GetStringAsync("http://bing.com/");
        ViewBag.MsdnContent = await client.GetStringAsync("http://msdn.com/");
    catch(Exception exc) {
        ViewBag.Error = exc.Message;
    return View();

This example uses some of the new async support in .NET 4.5, including the new keywords, new support in ASP.NET MVC that supports writing such methods, and the new HttpClient class which exposes a wealth of asynchronous methods.

As mentioned in my previous post on Visual Studio 11 Programming Language Advances, this support for asynchrony expands further into Visual Studio 11’s tooling.  For example, the Visual Studio 11 debugger has first-class knowledge of async methods (allowing you to step through the method as if it were synchronous), the code editor provides tooltips that show how to consume async methods using the new language keywords, the “Add Service Reference…” dialog automatically generates Task-based endpoints that can be consumed in async methods, the Concurrency Visualizer can highlight suspension points in async methods, and the MSTest unit test framework in Visual Studio supports async unit tests.

You can learn more about this async support on the Visual Studio Async page on MSDN.

Runtime Performance

Improvements for .NET 4.5 extend all the way down into the core of the engine, into the CLR itself, with multiple improvements made specifically with server scenarios in mind.

One key area of investment has been in garbage collection.  In .NET 4, we introduced “background GC” for the workstation flavor of the garbage collector.  This background mode, which is enabled by default, allows for Generation 2 collections to be performed concurrently with collections of Generation 0 and Generation 1.  What this means to developers is that application pause time is reduced significantly, which for client applications with rich UI can be a big deal, minimizing the number of hiccups that occur in the application’s responsiveness.  This need for reduced pause time is also relevant to servers, however, as servers need to remain responsive to incoming requests and often provide consistency on the latency with which requests are processed.  As such, .NET 4.5 sees the introduction of background GC for the server flavor of the garbage collector, as well.  As with the workstation GC, the server GC has this new capability enabled by default, so you don’t need to do anything special in your applications to reap the benefits.

The GC changes were made in recognition of the importance of memory management for various kinds of server workloads.  Another such change has to do with array sizes.  In .NET 4 and earlier, no object could be larger than 2GB in size, even in 64-bit processes.  For certain workloads that use large arrays, however, this size limit can be constraining.  As such, .NET 4.5 supports lifting the limit for arrays in 64-bit processes, such that arrays may be larger than 2GB.  This means, for example, that you could allocate an array of Int32.MaxValue Int32s, even though such an array will consume 8GB.  Large objects in .NET are allocated on a special heap, known not coincidentally as the Large Object Heap (LOH);  .NET 4.5 has also seen significant performance improvements to the LOH, including usage of better algorithms for managing free memory in the heap.

Another performance-focused improvement in the runtime is the new multi-core JIT compilation support.  In .NET 4 and earlier, just-in-time (JIT) compilation results in methods being compiled as they’re needed.  With .NET 4.5 and the new multi-core JIT capability, applications can make a few calls to methods on the ProfileOptimization class so as to highlight regions of the app where improved JIT compilation times are important.  The system will track what methods are used in that region, and on subsequent runs, those methods may be compiled on additional threads concurrent with execution of the program.  ASP.NET itself makes use of these APIs in .NET 4.5, so server apps written with ASP.NET benefit automatically.  This can be particularly beneficial for web app startup time, where some apps should see as much as a 30% improvement.

You can learn more about such performance improvements in the April 2012 issue of MSDN Magazine.

Base Class Libraries

The support for asynchrony through the .NET 4.5 libraries is quite extensive, with hundreds of new async methods exposed, and with quite a few performance improvements made for existing types in the Framework.  These new async methods span mscorlib.dll, System.Xml.dll, System.Data.dll, System.Web.dll, System.Net.Http.dll, and beyond.

Outside of asynchrony, though, there are a plethora of additions made to the core libraries that will positively impact server and cloud scenarios.  For example, .NET 4.5 includes the new ZipArchive and ZipFile classes for manipulating .zip files, as well as improvements to the existing compression support in the framework to improve compression ratios and speeds.

ZipFile.CreateFromDirectory(@"C:\MyBlog", @"Somasegar.zip");

The Managed Extensibility Framework (MEF) now includes support for generic types, support for multiple scopes, and a convention-based programming model.  The new System.Net.Http namespace (which contains the previously mentioned HttpClient type) provides components that allow for consumption of modern web services over HTTP, components that can be used in both clients and servers.  And much more.

The .NET team blog is a good place to learn more about what’s new in the BCL.


I’ve said for a long time now that .NET is a great environment in which to develop server and cloud applications, spanning from the private cloud (datacenter) to the public cloud, and I see this role getting even stronger with .NET 4.5.

.NET 4.5 is a modern enterprise framework. ASP.NET enables developers to build highly interactive server applications that use modern standards like HTML5 and CSS3.  Such applications are often built in terms of APIs and services that are also exposed to other consumers; ASP.NET Web API and WCF both provide solid frameworks with which to build these.  These applications and services also often need to support credentials, and the integration of Windows Identity Foundation into .NET 4.5 gives developers the tools they need to be successful with authentication and authorization.  ADO.NET and the Entity Framework enable developers to easily incorporate data into their server applications, with multiple work styles enabled, and with clean integration of validation and business rules.  With Windows Workflow Foundation, developers can create powerful workflow services for authoring distributed and asynchronous applications, and with WCF, these systems can communicate and integrate with any number of others enterprise solutions, from SAP to Oracle to SharePoint to Dynamics. Scalability is achieved with an asynchronous solution that spans the .NET runtime, libraries, and languages, and all of this runs on top of the highly robust, reliable, and efficient engine that is the CLR.

As you can see, there are a lot of new enhancements coming in .NET 4.5 that makes .NET a compelling programming environment for building applications for the cloud and server environments.


Comments (23)

  1. Fendi says:

    Any news on XP support (both for .NET and the CRT/C++)?

  2. Micah says:

    .NET 4.5 is *almost* a great enterprise framework. .NET 4.0 is a better enterprise framework, because it works with the most-used OS in the enterprise: XP.

  3. Stephen says:

    >>The WCF support in .NET 4.5 also ties in with the greatly overhauled asynchronous story in .NET 4.5

    This makes me worried.  I had hoped I could update my servers to run .Net 4.5 and keep my clients on .Net 4.0 (I like many many developers still have users on XP).

    Can I have servers WCF running .NET 4.5 communicate with client apps running .NET 4.0?  (Assuming I stay away from the Async stuff)?

    The fact that you will not talk to us about XP support leaves us to believe that either you don't care about your users or you are so far removed from your users you have no clue what it is we want discussed.  Most of the new features are nice, but XP support is so important that the lack of it, well it ruins it all.

    Please at least consider taking a few minutes out of your day and talk to us about XP support.  (What is the plan, what were the reasons for the plan and why did it take three-quarters of a year of development before the plan could be communicated to the users?)


  4. Auvitu says:

    Soma, how nice of you to ignore us. All problems are solved by merely ignoring them, right? What makes XP support so difficult to talk about?

  5. Leonidas says:

    What about silverlight? Is it going the way of the Dodo really?

  6. RRatan says:

    What about WPF?

  7. Chris Marisic says:

    Microsoft spent millions, if not many tens of millions of dollars establishing WPF. Visual Studio is entirely WPF.

    Silverlight is WPF in the browser.

    Stop with the sky is falling. WPF is not going any where. *** I even think all of next version of Office is WPF (I'm not sure if 2010 is).

    XP is a legacy operating system at this point. It is entirely being abandoned by Microsoft as of April 8, 2014.

    Is it reasonable to  expect current technology to work on legacy systems? No.

  8. Greg says:

    We're 11+ years into released .NET now. Can we please get the LOH fixed? MS keeps talking about compaction being expensive on it. Yep. I agree. But not nearly as expensive as an OutOfMemory exception.

    Write the compaction. Add it to .NET 5.0. Please.

  9. Chris Marisic says:

    Greg, are you sure that's not developer error? RavenDB is pure .NET and it has no issues with memory addressing.

  10. BBach says:

    When will Azure actually support .NET 4.5? Specifically – when will the tooling and packaging for local development at least become available? It seems we can use to it to create for clouds other than Azure sadly.

    Yes, I understand it is a beta, and I also understand we can hack together the install scripts needed to pull it in – but again, at least having the tooling for local development (local storage, local emulation) would enable us to proceed with new projects. There is a Go Live license so… I just do not want to see it languish until the fall or beyond.

  11. Micah says:

    I wish XP would go away too, but until you convince my customers that they need to upgrade, my shop can't use 4.5. Too bad.

  12. Ted says:

    Did you seriously delete the link from Neil Morgan's spam comment, but leave the rest of the comment up? Classy 🙂

  13. Chaitanya @chaittya says:

    Hey S.Somasegar,

    Its a very well written post on Cloud.

    We have recently published a series of blog post on Cloud and Cloud Security, do check it out and let us know how you find it: blog.harbinger-systems.com

    Looking forward to read more interesting stuff.


  14. Chris Marisic says:

    @Micah why do you care what your customers have? Develop behind SignalR, ASP.NET MVC etc and target any type of clients you want. Developing thick client apps is just fail for businesses.

  15. Micah says:

    @Chris: I like MVC-backed web interfaces for most projects, but a main component of our product has the requirement of working offline while accessing gigabytes of locally-stored data. HTML 5 localStorage is not yet up to the task.

    This thick client app has not been a fail for our business; we sell quite a few seats at about $3k a pop. Believe me, if I were allowed we would kill off XP support I would, but we know very well what effects that would have on our revenue.

  16. toub says:

    @Fendi, @Micah, @Auvitu: A discussion of platform support for Visual Studio 11 is now available at blogs.msdn.com/…/a-look-ahead-at-the-visual-studio-11-product-lineup-and-platform-support.aspx.

    @Stephen: Servers running .NET 4.5 can communicate with client apps running .NET 4 just as your servers running .NET 4 do today. Using async programming model improvements like await and Task in the WCF service operation has no impact on the wire protocol; you can still consume such services from .NET 4 with Visual Studio 2010.

    @RRatan: Soma’s blog post was about server-side development, which is why there’s no mention of WPF.  You can see a discussion of what’s new for WPF in .NET 4.5 at msdn.microsoft.com/…/bb613588(v=VS.110).aspx.

    @Greg: I’ve forwarded your feedback to the CLR team.

    @BBach: The FAQ at blogs.msdn.com/…/visual-studio-11-beta-frequently-asked-questions-faq.aspx states "Stay tuned for.NET Framework 4.5 support in Windows Azure Guest OS families, which is also coming in the future."  I don’t have more information to share at this time.

    @Ted: That was my fault; I was experimenting with the blog system, removed the link, and tried to remove the spam comment entirely, but apparently the latter didn’t take.  I’ve since tried again to remove it and it seems to have worked that time.

  17. Dennis says:

    @Stephen Toub:

    > A discussion of platform support for Visual Studio 11 is now available at […]

    Since noone from Microsoft seems to answer on that blog you linked, I will post here.

    The blog you linked is talking about doing _something_ for XP support after the official release of VS11, but it does not make it clear if it is going to be true support for XP in the compiler and the CRT, or just simpler multi-targeting to the old compiler from VS10.

    From the wording, it seems more likely that you are talking about just simpler multi-targeting. If so, this is NOT going to solve any problems.

    Could you please tell us what exactly you are going to do for XP? Or ask the authors of the blog you linked to do it?

    Thanks in advance.

  18. Micah says:


    The answer, based on my discussions with MS folks, is simple. If your software needs to run on XP, then do not adopt .NET 4.5.

  19. Not Responding says:

    I love when I read this nonsense about Microsoft being cross platform and being more open when the next version of IE is tied back into the OS and Microsoft products don't even work across their own operating system platforms. Come to think about it their products dont work smoothly period including Visual Studio. "Not Responding" is a great name for your products since that is the most popular window caption when using Microsoft software.

  20. Mike says:

    I have only one question. IF .NET has a great future then What is the purpose of putting METRO UI on Windows Server 8?

  21. Brad says:

    +1 for Greg's Large Object Heap request.  I'm tired of coming up with "schemes" to avoid heap fragmentation and the dreaded OutOfMemory exception (when I clearly have plenty available, just no contiguous blocks).

  22. Layla Driscoll says:

    @Greg and @Brad Compaction is one possible way to better use the memory to avoid running out of memory when there is still fragmented space.  As you say, you understand that moving these large objects is very slow.  In this release we took a step back  and looked for a way we could address the issue without just adding another big issue. We believe that better use of the memory during allocations gives the benefits needed without the large performance hit of compaction.

    We drastically changed the way the allocations work.  Previously once a spaces was deemed too small for an object, it would be unused from then on. Now, memory that used to stay unused will be used for any object that fits.  Since by definition the space left by a large object is at least relatively large, most times a some other large object will fit.

    Our test have shown that apps that had LOH OOM exceptions before, no longer do on 4.5.  Have you tried your app that hits out of memory exception on 4.5?  If your app still hits out of memory exceptions, we would like to know about it.

    Layla Driscoll, CLR Team

Skip to main content