Formerly asp.netPRO

November 2009 www.devproconnections.com Volume 8 Number 12

Building Independent Developer Connections

Visual Studio 2010 for ASP.NET Devs What’s Coming in ASP.NET 4 PLUS New Column Guest Editorial .NET Framework 4 Regular Columnists, New Products, What’s New and More! 2010

New Column Insider The Microsoft

Interview with Microsoft’s Dave Mendlen

November 2009 www.devproconnections.com U.S. $6.99 • Canada $9.99 Get ready for… in automated web testing

Presenting Web Testing Tools automating advanced ASP.NET AJAX and Silverlight applications

WebUI Test Studio Point-and-click web automation. Seamless Visual Studio integration.

Click-and-play interface for codeless web automation. Automatically generate common veriöcation or synchronization tasks.

Unique browser abstraction allows a single test to be recorded just once and played on multiple browsers without re-recording. Automate advanced ASP.NET AJAX applications by using dynamic page synchronization, waiting on AJAX and more. Superior testcase maintenance. Validate changes right on the spot without executing the whole test. Beneöt from the VSTS TFS to jumpstart a test the familiar Visual Studio way.

WebAii Testing Framework Free code-based web automation

ASP.NET AJAX and Silverlight automation. Quickly build functional tests for complex AJAX scenarios, client-side functionality, or bind test steps to a data source. The built-in Silverlight Extension mimics UI XAML elements in Silverlight. Multiple browser support improves browser compatibility testing by allowing a single test to be executed against all major browsers: IE, FF, and for Windows. Integration with various unit testing frameworks such as VS Unit testing, NUnit, MbUnit and XUnit. www.telerik.com/web-testing-tools

ASP.NET AJAX WinForms WPF Silverlight Reporting OpenAccess ORM Sitefinity CMS Testing Tools

US Sales: +1.888.365.2779 Germany Sales: +49.89.8780687.70 Europe HQ: +359.2.80.99.850 e-mail: [email protected] InThisIssue November 2009 | Volume 8 Number 12

Columns CoreCoder: A Runtime Environment for Two 18 Dino Esposito explores the architecture of the ASP.NET MVC run- time environment and discovers that it’s exactly the same as in ASP.NET Web Forms.

Federated Security: A Crash Course in Windows Identity Foundation 22 Michele Leroux Bustamante introduces Microsoft’s federated security by giving examples of confi guring WIF for the WCF service and using WIF to build a security token service and passive federation for ASP.NET.

Microsoft Insider: What’s New with the Microsoft Web Platform 28 In this new column, Laurence Moroney tells us what’s hot on the Microsoft event horizon. This month he looks at new developments for the Microsoft Web Platform.

Cover Photo by Jim Molnar Exploring WCF Services: Windows Extensions Cover Design by Matt Wiebe 30 Windows Application Server Extensions (aka “Dublin”) contains Cover Story powerful enhancements that improve confi guration and monitoring for WF and WCF services and augment hosted services. Zoiner Dave Mendlen on Visual Tejada takes you through the new features in Dublin Beta 1. 11 Studio 2010 In a wide-ranging dis- Silverlight 101: Collecting Data with Silverlight’s cussion of what’s new 36 DataForm Control in Visual Studio 2010, DataForm, a new Silverlight 3 control, simplifi es collecting, defi ning, Dave Mendlen shares his and accessing end-user data. Dan Wahlin kicks off a multipart series thoughts with executive by introducing DataForm and explaining how data can be bound to it. editor Sheila Molnar on BackDraft: Making History with the Visual Studio features he thinks will be 64 Historical Debugger especially compelling for What matters most—language, framework, or development the developers who read environment? Jonathan Goodyear shares his thoughts on that DevConnections. question and where the Visual Studio Historical Debugger fi ts in.

Features Departments Web Development in the Next Decade 42 Visual Studio 2010 is the first version of Visual Studio that natively 6 Executive Editor’s supports the two paradigms of ASP.NET development: ASP.NET Web Comment by Sheila Molnar Forms 4 and ASP.NET MVC 2.0. Dino Esposito previews enhancements 8 Guest Editorial and new features. by Laurence Moroney Renovations to .NET 4.0’s Entity Framework 10 Crossword Puzzle by Anne Grubb 47 Julia Lerman introduces 11 improvements to Entity Framework 4, including intelligent entity naming, support for POCO objects, and 60 Advertising Index foreign language support. Products and What’s Coming in Microsoft AJAX? Reviews 52 Microsoft’s goal is to create a single that developers can use when building ASP.NET Web Forms, ASP.NET MVC, and even pure 61 New Products Product news from Intersoft AJAX applications. Stephen Walther reveals the changes you’ll see in Solutions, ComponentOne, Microsoft AJAX over the coming months. Pitney Bowes Business Insight, Red Gate , Required Reading: Web Hosting Industry Trends JetBrains, and Stimulsoft. 56 Steve Schofield tells you about key trends to be aware of when you’re selecting a hosting provider.

2 November 2009 | www.DevProConnections.com

Powered by Microsoft and DevConnections

FOCUS ON APPLICATION LIFECYCLE SILVERLIGHT 3 .NET FRAMEWORK 4.0 MANAGEMENT WCF ASP.NET WPF WINDOWS WORKFLOW 4.0 WINDOWS AZURE ENTITY FRAMEWORK AJAX PLATFORM ... AND MUCH MORE

MARCH 22-25, 2010 • LAS VEGAS, NV Bellagio Hotel and Casino

>> REGISTER EARLY—Take advantage of our Early Bird Special Room Rate of $149! the launch of Visual Studio 2010 Celebrate with Microsoft execs and colleagues around the world!

BE THE FIRST TO EXPERIENCE VISUAL STUDIO 2010 AS IT LAUNCHES IN LAS VEGAS Dive into the latest products and Learn from Microsoft architects technology with our no-hype and industry experts 100+ MICROSOFT AND in-depth sessions Build valuable relationships with INDUSTRY EXPERTS Separate technology myths from attendees from around the world reality as you network with the 200+ IN-DEPTH SESSIONS Obtain relevant technical advice authors whose books and from Microsoft product teams and columns you read INDUSTRY PARTY consultants

UNPARALLELED WORKSHOPS

The cutting edge event for developers and DBAs Ready to turn your best ideas into better solutions?

Be the first to see Microsoft® Visual Studio® 2010

MARCH 22, 2010 LAS VEGAS, NEVADA

CO-LOCATED WITH

CHECK WEB SITE FOR DESCRIPTIONS OF SESSIONS AND WORKSHOPS www.DevConnections.com • 800.438.6720 • 203.400.6121 • Register Early! ExecutiveEditor’s Comment By Sheila Molnar

Kim Paulsen, Senior Vice President, Penton New Media Group Welcome to the New Shirley Brothers, Developer Market Manager Kim Hansen, Developer Market Publisher DevConnections Michele Crockett, Editorial and Custom Strategy Director Magazine! Sheila Molnar, Executive Editor, DevConnections and DevProConnections.com Anne Grubb, Web and Developer Strategic Editor elcome to the new DevConnections magazine! We’re the independent Amy Eisenberg, Executive Editor, IT Group Dave Bernard, Group Editorial Director, Custom Media community for and .NET Framework develop- ment. Look here to find thorough how-to articles written by experts in EDITORS W Karen Bemowski, Jason Bovberg, Linda Harty, the field. In these pages you’ll read many points of view—from Microsoft insid- Megan Bearly Keller, Caroline Marwitz, ers to in the trenches implementing heterogeneous solutions. Chris Maxcer, Lavon Peters, Rita-Lyn Sanders, Zac Wiggy, Brian Keith Winstead These are exciting times to be a developer. To echo Dave Mendlen in this Brian Reinholz, Production Editor month’s interview, developers will be on the cutting edge that pulls the world CONTRIBUTING EDITORS out of financial doldrums and into the next era of technological growth. As Dave Jonathan Goodyear and Mike Riley says, “Our analyst community tells us that they believe that developers are going TECHNICAL EDITOR to be a key gear in the driving of the economy.” Anand Narayanaswamy

CONTRIBUTING WRITERS Make New Friends Michele Leroux Bustamante, Dino Esposito, Bilal Haidar, Brian Mains, and Dan Wahlin This month, be sure to check out new columns in DevConnections: • new guest editorial column written by a different industry expert each month

ART & PRODUCTION • new Microsoft Insider column written by Laurence Moroney, who will share Layne Petersen, Art Director the inside scoop on emerging technologies at Microsoft Matt Wiebe, Senior Graphic Artist Linda Kirchgesler, Production Director • Each month we’ll run a set of articles focusing on a technology or trend. This

AD SALES month’s focus looks forward to the major 2010 releases—Visual Studio and Brenner Fuller, Western Regional Sales Director .NET Framework 4.0. (603) 746-3057 Jon Hampson, Director of International Sales • regular interviews with industry leaders (603) 371-2131 • a new regular column by Michele Bustamante on federated security Julie Thibault, Eastern Regional Sales Director (603) 722-0131

REPRINT SALES But Keep the Old Diane Madzelonka (216) 931-9268 Many old friends will also be back, and they’re all focused on delivering great LIST RENTALS, WALTER KARL, INC. developer content for current and upcoming versions of ASP.NET, Visual Studio, 2 Blue Hill Plaza, 3rd Floor, Pearl River, NY 10965 Marie Briganti (845) 732-7054 and .NET Framework. Rosalie Garcia (845) 732-7027 • CoreCoder column, by Dino Esposito CIRCULATION & MARKETING • a regular feature on WCF and WF, by Zoiner Tejada Evelyn Bridge, Marketing Director • continuing coverage of Silverlight, by Dan Wahlin Marie Evans, IT Group Director of Audience Development [email protected] ...... (970) 203-2761 • the BackDraft column—Jonathan Goodyear’s acerbic look at developer culture • product reviews, industry news, book reviews, and the crossword puzzle Customer Service .....(800) 650-1804 (US and Canada) ...... 44-161-929-2800 (Europe) Aligning with the DevConnections Conferences As I mentioned last month, by taking the name DevConnections, this magazine is aligning with Penton Media’s well-respected DevConnections conferences. We want to ensure that you’ll see the same high-quality developer content in your magazine that the conferences deliver.

We’re also in the process of relaunching our website, DevProConnections.com.

Sharon Rowlands, Chief Executive Offi cer You’ll find our developer eLearning offerings there, as well as in our online [email protected] store, LeftBrain.com. We’ll continue to publish developer newsletters regularly,

Jean Clifton, Chief Financial Offi cer plus offer podcasts and webcasts and DevConnectionsTV. Here’s to new [email protected] beginnings!

Sheila Molnar ([email protected]) is executive editor of DevConnections.

6 November 2009 | www.DevProConnections.com WORDASP.NET / ASP / PROCESSING / .NET / ACTIVEX COMPONENTS ( WHAT YOU SEE IS WHAT YOU GET )

TX Text Control Version 15.0 released!

TX Text Control Sales: Word Processing Components US +1 877 - 462 - 4772 (toll-free) for Windows Forms & ASP.NET WWW.TEXTCONTROL.COM EU +49 421 - 33591 - 0 GuestEditorial By Laurence Moroney

What’s New in .NET Framework Version 4.0

s you know, the .NET platform continues to evolve 6. Networking. There are many improvements to how and grow. We’ll soon see the release of .NET integrated Windows authentication is handled by classes AFramework 4.0, but I wanted to give you a quick in System.Net and its related namespaces, including the run-through some of the features that you’re going to see, extended protection features of Windows 7. just to whet your appetite a little! 7. ASP.NET Web Forms. There are many updates to ASP Version 4.0 is a huge release, so this editorial can’t do it jus- .NET Web Forms for building web applications, including tice, but let’s look at some of the highlights. the ability to set meta tags, more control over view state, the ability to persist selected rows in data controls, and 1. Parallel Computing. A new programming model for more control over the HTML rendered by controls such as multithreaded and asynchronous code is being introduced the FormView and ListView. in .NET 4.0. This will greatly simplify the work needed to deal with building applications that take advantage of paral- 8. WPF 4 Improvements. There are many improvements to lelism. One great example of these is in PLINQ, paral- Windows Presentation Foundation (WPF) in version 4, includ- lel extensions to the LINQ framework. ing a number of new controls, extensions to the UIElement providing Multi-Touch capabilities, easing functions for more 2. Performance. There are many performance improve- natural animation and Windows Chrome updates to match the ments, designed to make your applications run faster and Windows 7 and Windows Vista styles—to name just a few! use a smaller memory footprint. One such is Lazy Initial- ization, which means that the memory for an object isn’t 9. Managed Extensibility Framework. In addition to the allocated until it’s needed. It allows you to spread object major improvements to WPF for version 4, a new Managed allocations evenly across the lifetime of your application. Extensibility Framework (MEF) has been introduced. This It’s easy to use, too—you simply wrap your type inside a allows you to build extensible and composable applications. System.Lazy(T), and the framework will do the rest. The framework lets you specify the points where your application can be extended, and the services and interfaces 3. Dynamic Languages. The where it can be consumed, or it can be a consumer. (DLR) adds support for dynamic languages in the CLR. This allows languages such as Ruby or Python to use the .NET 10. Communications. In the interconnected world of the Framework. web, the ability for applications to communicate is para- mount. .NET continues its support for this in the evolution 4. Side-by-Side Execution. In-process side-by-side hosting of the Windows Communication Foundation (WCF), which lets your application use different versions of the CLR in the has been enhanced with many new features, including sup- same process. This allows you to run a .NET 2.x, .NET 3.x port for WS-Discovery, Standard Endpoints, and a new set or .NET 4.x application in the same process, greatly easing of Workflow Services that allow you to build workflows migration worries. that send and receive data.

5. Base Class Library (BCL) Improvements. The BCL This has been just a brief summary of some of the good- has a number of new improvements and upgrades. These ies you can expect to find in .NET Framework 4. Keep an include the BigInteger class, which provides arbitrary preci- eye on DevConnections (www.devproconnections.com) and sion while supporting all the standard integer operations, on www.microsoft.com/net for more information and for including bit manipulation; the SortedSet class, giving a updates as we roll towards its release. self-balanced tree that maintains data in sorted order after updates, inserts, deletes, and searches; and many upgrades to Isolated Storage. These are just three samples of what is Laurence Moroney ([email protected]) is a senior product going on in the BCL—check the release for more. manager at Microsoft, working on the Web Platform.

8 November 2009 | www.DevProConnections.com

Test Your DevConnections Sponsored by Knowledge By Anne Grubb www.devexpress.com/crossword

This month’s Crossword Puzzle is sponsored by DevExpress. The first 20 partici- pants will receive a DevExpress t-shirt, and all participants will be entered in the monthly drawing to win DXperience™ Enterprise – by DevExpress. To receive your t-shirt and enter the drawing, complete the puzzle, include your contact information, and fax to 970-667-2321 by November 30.

Across 2. “One-stop shop” tool that lets you 13. New property in ASP.NET Web Forms 24. A component of the Microsoft Web install various Microsoft Web Platform 4 that lets you disable the viewstate Platform. technologies. selectively for certain controls. 25. Another component of the Microsoft 4. Real name of “Dublin.” 15. A web hosting industry trend. Web Platform.

5. Microsoft’s Mendlen: “For the first 16. Command-line web app deployment 26. Engine in VS 2010 that adapts devel- time, ______can be used inside tool in Visual Studio 2010, for short. opment-time content of web.config to Visual Studio in a first-class way.” include production environment settings. 20. New Silverlight 3 control that simplifies 7. New feature in Dublin that provides IIS data collection. UI enhancements for WCF configura- Down tion editing. 22. The new identity model framework for .NET. 1. New debugger in VS 2010. 12. A or service that 3. Microsoft’s Mendlen: “We’re trying to authorizes access based on the claims 23. One of two HTTP modules supplied by bring the LINQ and ______tech- presented in a security token. WIF to support passive federation. nologies closer together.”

6. One of two profiles that WS-Federation 1 supplies for federation with WS-Trust.

2 3 8. The heart of Dublin’s configuration man- agement capability.

4 9. Another of two profiles that WS-Feder- ation supplies for federation with WS- 56 Trust.

10. The area where most of the Visual 7 Studio 2010 enhancements are concen- 8 9 trated. 10 11 11. In a federated security scenario, this 12 participant is responsible for authenti- cating the subject.

13 14 14. Single AJAX library that unifies the

15 AJAX Control Toolkit, jQuery, and ASP. 16 17 NET AJAX. 18 19

20

21 17. ASP.NET MVC 2 now includes built-in support for these attributes.

22 18. Microsoft team development and source-control tool that’s part of the Visual Studio line. 23 19. VS 2010 code-writing enhancement that

24 lets you insert code snippets in the text editor.

25 21. A web hosting industry trend.

26 Anne Grubb ([email protected])

Please visit www.devproconnections.com is web and developer strategic editor for Look throughout this issue of DevConnections for answers to this puzzle. DevConnections, System i NEWS, Windows for answers to the puzzle clues. IT Pro, and SQL Server Magazine.

10 November 2009 | www.DevConnections.com CoverStory

By Sheila Molnar Photos by Jim Molnar Dave Mendlen on Visual Studio 2010 New tools for building code and maintaining team cohesion

n a sunny Sheila Molnar [SM]: Thanks for meet- Carly Fiorina. Captains of industry. But ing with me to talk about Visual Stu- the pace was incredible. And after that OSeptember dio 2010. I’ like to start by giving our I moved on to do a few other roles at day, Sheila readers some background on your role Microsoft. The last one before coming and what you’ve done at Microsoft. back to developer was to run the Win- Molnar, the dows consumer marketing team—I did executive editor Dave Mendlen [DM]: I’ve had a that in the lead-up to the Vista launch. of DevConnec- unique set of experiences at Microsoft. At Windows Vista I shifted back to I’ve been here for about 12 years. I Developer; I found home again, and tions, caught started in the developer marketing I’ve been here ever since. up with Dave group as a product man- ager. I rose up to lead the team of SM: Well, that’s good timing there. As Mendlen, the planners for .NET. That was a crazy you know, in DevConnections we’re senior director time as we were battling , and we broadening our coverage from ASP needed to have a great response. We .NET to all things Visual Studio and of developer invented this idea of web services, and .NET Framework. Since our readers are marketing, then we connected them for develop- mostly enterprise ASP.NET developers, ers in a very simple way. That was can you give them a high-level view of on the Micro- what .NET was all about. I was then the enhancements in Visual Studio 2010 soft campus. recruited away to be a speech writer that would matter most to them? Mendlen and his for Steve Ballmer, which I did for about three years. DM: I think there are a few catego- team are hard at ries that customers will look at Visual work on the final SM: That must have been an interest- Studio 2010. One category is a set of ing job. technologies and features of interest to stretch of prepa- every . The second category rations for the DM: It was a great job. I say it was the is a set of pro features that platform- best of times, it was the worst of times. enable technologies like Windows and release of Visual Because that job was so exciting— Office. The last category is integration Studio 2010. meeting people like Michael Dell and across teams. When we talked to you a

DevConnections | November 2009 11 Cover Story Dave Mendlen on Visual Studio 2010 year ago, we talked about wanting to break down the walls DM: We’ve done a great job of working with the environment. between the teams that make up the We brought in a set of usability experts and tested, really for process. Today I can talk about how we connect all the teams the first time, to make sure that we had the right fonts, the together. Team Foundation Server is one aspect of it. I’ll start right seraphs, the right font sharpness, the right contrast. with the first category, which includes those technologies that Developers sit in front of their computers all day every day, apply to everyone. and so if you have the wrong colors you can cause eyestrain. So we’re able to make all those customi- SM: So by everyone do you zations and really build the best environment for mean different types of devel- a developer to spend all day looking at it. Your opers? question is “hey, can I change the way this behaves and interacts?” The answer is yes, in Tools Options, DM: This is if you’re a devel- of course you can make changes to the way the oper and you’re using Visual experience looks. But the developer can also eas- Studio primarily, whether ily extend the environment to make it do things it you’re an ASP developer never did before. So if you don’t like the idea of or a Windows developer or translucent highlighting, you can do crazy things doing a lot of business logic. like put a cloud around it or put a halo around it, Regardless of what kind of or you can do whatever you like. You can darken coding you’re doing, there is all the text other than the text you’re working on. some kind of fundamental WPF enables you to build that level of extensibility goodness that we’ve infused into the environment. into the system, indepen- The other thing we think about for all devel- dent of type. We’ve made opers is language innovation. One innovation enhancements in the IDE. It we’ve talked about is the new F# language for a has been completely rebuilt in Windows Presentation Founda- set of science and finance customers that need a functional tion (WPF). It was originally native code, and we ate our own to do very specific things. dogfood and built the environment entirely in WPF. That gave us a number of benefits; one is multi-monitor support. You can SM: Do you think the ASP.NET programming community have one screen for your code and another screen for your user would be interested in this? interface and maybe another screen for your testing results. You can take advantage of all the monitors you’ve got and you DM: There will be ASP.NET developers that have some can tear off windows and put them wherever you like. That’s relationship to finance or to science, but F# is probably a feature we’ve wanted to deliver to customers, and we finally less mainstream than some of the other features, such as can because we have it built in Windows Presentation Foun- parallel programming. Parallel programming is going to dation. WPF also gives us a lot of extensibility. That’s critical change the landscape. Every computer, even the low-end to us because we’re both a platform company and a platform notebooks that are coming out, have at least two cores. In company! We even make our tools a platform on which others many cases developers are buying machines that have four. can build. ISVs in the Visual Studio Integration Partner (VSIP) In some cases I’ve seen even more. If you’ve got a desk- program build software to run in Visual Studio that they sell top, you might have eight or 16 or more. And so if you’re to developers. Those VSIP partners have been dying to get the building an application, you want to take advantage of all kind of extensibility we now have. It enables us to do really the horsepower that your customers will have. And, histori- interesting things for customers when we partner up with cally, that’s been challenging. Of course we’ve had 64-bit these VSIP guys. For example, something I saw in prototype to address more memory, but now what do you do to take was—you’re looking at your code, and you can take an artifact advantage of these other processors? So parallel program- (a diagram or even a scanned-in bar napkin) that has the pro- ming lets us relatively simply enable the developer to light posed architecture. And you can lay the artifact in right there in up those processors so they can, with a couple of keywords your code. Traditionally that’s been a separate graphic file, but in managed code, build a loop that’s entirely supported you can actually have the artifact sitting right there with code. by multiple processors. You want to distribute load to core Those are the kinds of things we can start doing because we one or to core two. All of that is built into Visual Studio. can take advantage of the richness of WPF. So from parallel programming to the IDE to functional pro- gramming languages, those are the core areas where I think SM: Is it possible to change the settings in the IDE if you everybody is going to find value. Then I talked about the don’t like a particular WPF setting? For example, the high- pro developer. light feature. It’s translucent and pretty, but can you go back to “classic” if you don’t want to use it? SM: That’s the market we’re aimed at.

12 November 2009 | www.DevProConnections.com

Cover Story Dave Mendlen on Visual Studio 2010

DM: In the pro developer market there’s a lot of interest in think about ubiquity of platform. platforms. The SharePoint platform is obviously exciting to ASP developers. For the first time, SharePoint can be used SM: So back to Azure. What’s the news for ASP.NET inside Visual Studio in a first-class way. You can create a new developers who are thinking about moving to cloud devel- SharePoint project, file a new SharePoint project, and work opment in Visual Studio? with that project offline. When we taught developers how to build applications with Visual Basic and Windows, the meta- DM: The developer who’s actually the most prepared for phor was simple: You create a form, you drag things from a Microsoft’s cloud offering Azure is the ASP.NET developer. toolbox, you double-click the button, write a little code, and That is the technology substrate that is in fact our Azure now you have a Windows application. We took that metaphor offering. So people familiar with building ASP.NET applica- and applied it to building web applications, database applica- tions are the most well-positioned to move into the cloud tions, and now SharePoint applications. We’re going to take because they already understand the core concepts. They your skills and your code, and we’re going to move it forward. already have the code. In fact, much of their code will just move right over to Azure. In terms of the simplicity of SM: So you think that this will be more appealing to develop- usage—you file a new project to create a new web appli- ers, some of whom haven’t leapt into the SharePoint space? cation, and then you’re going to want to be able to work offline because it costs to use the Azure service. So we have DM: SharePoint has been this wild success for Microsoft. an offline way of debugging your application within Visual It’s just everywhere, and yet the developer population Studio so you can build the project, get it working the way hasn’t yet had the right tools to be able to kind of support you expect it to, and then deploy seamlessly to Azure with- the users. With Visual Studio 2010, we have the tools even out having to do something special outside of the IDE. in the beta to enable them. People are also excited about having great tools to build SM: We were talking about professional developers. So rich Windows 7 applications. So you want to have the Windows 7 rib- bon, you want to take advantage of touch, you want to light up Windows 7—developers now have those tools built into the Visual Studio 2010 beta. The other platform area is Azure. Azure tools are also built right into Visual Studio. So right from within it you can file a new proj- how about database professionals? What is there for them? ect and build an Azure application that connects right up to the cloud. You can develop; you can debug. DM: One of the challenges is: How do we tear down the walls that make up the software development lifecycle? One of those SM: Azure is platform agnostic, so this would be accessible walls sits between developers and database administrators. to non # or VB programmers through the IDE? Traditionally developers need access to tables in order to build their applications, and oftentimes they want to propose some DM: There is a class of developer that may not want to use changes. The DBA is never going to give the developer access Visual Studio to build an Azure application. Azure is agnos- to the production database, for good reason. But developers tic, as it should be. It’s a platform. So if you decide that you still need the opportunity to work on it. With the database want to take advantage of Azure outside of Visual Studio tools built into Visual Studio Team System, the developer can absolutely, that’s possible. Obviously as the Visual Studio take the database and pull it entirely offline, local to his envi- guy, I think Visual Studio is the best way to do it. You talked ronment. The developer can create his own test data. He can about this idea of platform ubiquity or using technology propose changes to the database. The developer can establish across platforms: One of the areas in which we invest deeply requirements for the database, propose those things, and then is in Silverlight. And Silverlight is where you can build check them in as a recommendation to the database admin- applications in the same way as you can with ASP.NET—the istrator. Now the DBA can look at that and decide whether rendered application is somewhat platform agnostic. You can that’s appropriate or inappropriate. That enables a relationship look at that ASP application in Safari or —it’s the web. and a conversation between those two people that’s much The same thing is true of our Silverlight executions. We’ve more productive than just yelling across a conference table. taken the .NET Framework and built a scaled-down version of it that is Silverlight. And that Silverlight technology will SM: And this is Visual Studio Team System. render and run in a rich way on the Mac, on Linux, and on Windows. So, from a platform perspective, that’s how we DM: Developers use the database tools that are built into

14 November 2009 | www.DevProConnections.com Visual Studio Team System, and they check the database in SM: Just going back up the food chain all the way to archi- and out of Team Foundation Server. That’s the server that tect: Is this something that architects would use for modeling? lets everybody share. So teams can break down walls using Team Foundation Server. DM: I’m so glad you said “architects” because one of the areas where there’s been some animosity is between archi- SM: Obviously Team Foundation Server can be really useful tects and developers. Developers dearly want and need the in the enterprise. However, a lot of our readers are consul- ability to view the architectural layout of their existing appli- tants. How would you see them using something like this? cation. Traditionally, that’s been an architect’s tool. That’s a challenge for developers, because they’ll spend weeks some- DM: Team Foundation Server today is an industrial-strength times when they inherit a codebase trying to understand how source control tool, a work-item tracking tool. A SharePoint it works. When they make a change they want to understand portal goes along with it. It is prime time and ready to rock the impact. So we built a tool that lets a developer interrogate for the biggest implementations of development environ- an existing application and build a diagram that represents ments. For this release of Visual Studio we asked, “what do what’s actually going on in an existing application in a way we do to support the Visual Source Safe (VSS) customer?” that architects and developers are used to seeing: the UI layer, And while we’re not announcing the business logic layer, the database layer. And, seeing all the today what that is, I’ll tell you that very specific functions and subroutines that make up these we’ll shortly disclose good news for applications at a high level, the developer can then drill all your readers. the way down into code at whatever level of detail he wants.

SM: We look forward to hearing more SM: So is this pulling Oslo into Visual Studio? on that! So, shifting slightly, what about coverage of the Entity DM: No, this isn’t yet related to Oslo. We’re still rationalizing Framework in 2010? how we bring all these technologies together. This is even before that. I can’t even imagine how much better it’s going DM: We’re trying to bring the LINQ to get when we pull those technologies in. Now the devel- and Entity Framework technologies oper has access to the architecture. The architect can now closer together. We’re rationalizing that look at it and propose what they want the architecture to from an organizational perspective and be. The architect from a technical perspective. This will continue to evolve wants to be able over 2010 and into the future. For us it’s about making sure to say, I want this there’s one way of doing it. We had two ways of doing it, relationship with and so now we’re collapsing these two technologies together. the user interface and the database SM: That’s another development we need to keep our eyes and the business on! And can you say more about the third general point logic. I don’t ever you were making about breaking down walls. want the UI talk- ing to the data- DM: Breaking down walls—people using Visual Team base directly. I System work in enterprise environments and engage with always want it to designers. Sometimes these graphic designers are also flow through the developers that build the user interface (UI). These people business logic, for want the flexibility and the freedom to be able to build a example. So I as rich experience, but they also have to be sensitive to the an architect can fact that somewhere downstream there’s a tester. And that say that’s a policy. tester has built a set of tests that expect that the text box is You can’t break over here, the button is over here. We built a set of tools for my architecture. the tester to capture the attributes of the screen, so when So when you check in code, Mr. Developer, it must adhere a graphic designer makes a set of changes the tester can to that policy. Now the developer has a view into what’s be informed. The coded UI test feature enables the tester happening on the one side, and the architect can see what to test the UI baseline experience and then rerun the base- he wants it to be. Now they can have a great conversation line against future iterations of the application. The tester around what’s going on. can simply hit Play, and it will tell him that something has changed. It might be good, it might be bad, but at least the SM: So this is the democratization of the process that we’ve tester isn’t condemned to figure that out by himself. been hearing about?

DevConnections | November 2009 15 Cover Story Dave Mendlen on Visual Studio 2010

DM: Absolutely. We’re just trying to tear down those walls. use all the great tools that come along with it. That’s one You mentioned the tester earlier. The biggest collisions have example, but you can imagine other third-party examples. happened between developers and testers. Testers have to convince developers that in fact their code is broken. We built SM: I don’t know if ASP.NET programmers would be using a set of tools for testers that capture a screen shot a lot of COBOL. and a video of what’s going on as they’re test- ing the application. Now they can check that into DM: They might be using Team Foundation Server, and when the developer PHP, though! gets the bug, not only does he get a bug, but he can hit the Play button on the video and see it! SM: There you go. Let’s The best part is not only do we capture the screen talk about the Visual Studio and the video, we capture what’s happening on languages. I understand that that user’s machine. All of it. That gets checked there are some productivity into Team Foundation Server, too. The developer advancements for VB and C#. may not have the same environment established on his machine. So he can run through the test on DM: One of the things we his machine and not get the same results. But now heard from our customer because he’s got all of the test machine experience base is that there were he can see the specific environments of that test unique features that were computer. It’s revolutionary. in the VB side but not in the C# side, and vice versa. SM: So would you say that this a big reason to We actually pulled the buy Visual Studio 2010? teams together, and now that single team builds both languages. There may be a few DM: I think it’s one of the biggest reasons to buy. If you’re a instances where a language innovation may show up in one developer, the ability to re-create when a bug happened, what language slightly before the other, but that will always be happened, so that you can now fix it, especially if you’re work- an anomaly because we now have a single team. ing across geographies. Now we have that kind of precision. SM: We’re in a recession, so readers are looking for a cost- SM: I’m interested in how you work across non-Microsoft effective solution. Do you see Visual Studio as cost effective? platforms. Is there any role for Visual Studio in working with open source? DM: Our analyst community tells us that they believe that developers are going to be a key gear in the driving of the DM: I’m probably not the right person to talk about open economy. They see that technology and specifically the source, but the idea of working across platforms is criti- ability to create great intellectual property that can be mon- cal to us. A great example is the ability to take SQL Server etized will be a critical component that drives pulling us offline and make changes and generate test data, but it only out of the recession. Obviously, we want to do everything works with SQL; we often work with our Visual Studio we can with respect to enabling our customers to afford it, Integration Partner program with third parties to help us to use it, and to be successful with it. reach these non-Microsoft platforms. We’re not the right folks to do Oracle or DB2, but we can find a partner like SM: We’re looking forward to the launch of Visual Studio. Quest Software. Quest is a partner who did the Oracle How are those plans shaping up? implementation and the DB2 implementation of that. So whenever there’s an obvious market need, we go work DM: We’re very excited about the launch of Visual Studio with the ecosystem to fill in those blanks. 2010. We’ve got a couple more milestones left. We still have to ship the next beta and get feedback from our customers. SM: For example, the Visual Studio IDE isn’t set up for So far the customer feedback has been overwhelmingly posi- programming in non-Microsoft languages. Would that be tive. I haven’t seen this kind of excitement since 10 to 12 something that a partner would pick up? years ago when I first joined the developer group. People are just really excited about it—especially the high-end features DM: Yes, a great example of that is MicroFocus. They have such as Team System; they’re really pretty remarkable. their own development environment that enables the cre- ation of COBOL. You can take the language of COBOL and instantiate it inside of Visual Studio. MicroFocus is a partner Sheila Molnar ([email protected]) is executive editor of of ours, so you can put COBOL inside of Visual Studio and DevConnections.

16 November 2009 | www.DevProConnections.com On a dark and stormy night, a freak chemical reaction charged with a lightning storm unearthed a champion for developers everywhere who are striving to create Killer Apps. Visit infragistics.com/killerapps where you can hear the story of Gort and learn how to create your own Killer Apps.

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91-80-6785-1111

Copyright 1996-2009 Infragistics, Inc. All rights reserved. Infragistics and the Infragistics logo are registered trademarks of Infragistics, Inc. CoreCoder LANGUAGES: C# .NET FRAMEWORK VERSIONS: ASP.NET MVC By Dino Esposito

A Runtime Environment for Two Why ASP.NET Web Forms and ASP.NET MVC applications can run side by side

hen a new hi-tech toy makes it to the market- was introduced with IIS 6.0: application pools to group place, many of us rush to be among the first multiple Web applications under the same instance of a Wto own the precious thing. This is more or less worker process. The worker process changed to be a stan- what happened when Microsoft announced the first Com- dard IIS executable configured with specific extensions to munity Technology Preview (CTP) of ASP.NET MVC. ASP. process specific requests such as ASP.NET requests. NET MVC generated a lot of interest because it was cool, techie, new, and—last but not least—well designed and full Later on, IIS gained more built-in functionality to imple- of really good stuff. ment earlier in the process chain, and for any type of resource, many of the powerful features of the ASP.NET But what about ASP.NET Web Forms? Will ASP.NET MVC runtime (e.g., process recycling, output caching, and form- ever supplant the old-fashioned but certainly not obsolete based authentication). This is known as the integrated IIS ASP.NET Web Forms platform? In this article, I’ll dive into and ASP.NET request processing pipeline and it’s up and the ASP.NET runtime environment to unveil the steps running in IIS 7.0 on Windows Server 2008. involved with processing an ASP.NET request. You might be surprised to learn that both flavors of ASP.NET are built on The behavior of the IIS worker process (w3wp.exe) varies top of the same runtime environment. Every request sent to according to the version of IIS and the selected working mode an ASP.NET application is processed by the same runtime, for the application pool. Today, your hosted ASP.NET applica- then routed to either Web Forms or ASP.NET MVC. tion falls in either of two main scenarios. It can be hosted on IIS 6.0 or on IIS 7.0. If hosted on IIS 7.0, you can configure your Inside the Host Web Server application to work in integrated or classic mode. If it works in Any web application is hosted within a web server. Typically, classic mode, the runtime environment is analogous to IIS 6.0. for ASP.NET applications the web server is Microsoft IIS. A web server spends most of its time listening to a variety of ports, including port 80 where HTTP packets are usually forwarded. IIS is no exception. The details of what happens when a request is intercepted depend on the programming interface of the web server and any functionality provided by external modules linked to the web server. As far as IIS is concerned, significant differences exist between IIS 6.0 available on Windows Server 2003 and IIS 7.0 coming with Windows Server 2008. You’ll notice even greater differences with IIS 5.0 on Windows 2000 Server. Figure 1 summarizes architectural changes in successive versions of IIS that had an impact on ASP.NET applications.

In the beginning, the ASP.NET runtime was a separate world running its own worker process and receiving input Figure 1: Architectural changes occurring to IIS over the years from IIS through a named pipe. A significant innovation

18 November 2009 | www.DevProConnections.com The default with IIS 7.0 is the integrated mode, and I’ll focus mostly on that.

First Cries of a Request In both IIS 6.0 and IIS 7.0, any incoming HTTP request is captured by the http.sys driver and posted to the request queue of the appropriate application pool. In this context, “application pool” is a blanket term that identifies a worker process and a virtual directory. So when a request arrives, the driver looks at the URL and queues the request to the corresponding application pool. The request is then ana- lyzed and forwarded to the appropriate extension module to be serviced. Extension modules claim requests based on Figure 2: The runtime environment for an ASP.NET MVC application the extension of the request URL. of the request is shown in Figure 2. A typical ASP.NET Web Forms request contains a URL that ends with the .aspx extension. The ASPX extension is associ- The Routing Module ated with a particular IIS extension that loads the CLR and Since ASP.NET 3.5 SP1, the URL routing engine—originally goes through the list of registered HTTP modules as config- designed to be a part of the ASP.NET MVC framework—has ured in the web.config file. For an .aspx request, this model been taken out of the framework and integrated with the remains the same regardless of IIS version and configuration. full ASP.NET platform.

An ASP.NET MVC application requires some changes to the Once installed, the URL routing module intercepts any default ASP.NET runtime environment to work the way it requests for the application that could not be served other- works. The key change is the introduction of an HTTP module wise by IIS. If the URL refers to a physical file, the routing that captures any incoming request early in the lifecycle and module ignores the request, unless otherwise configured. tries to recognize it as an ASP.NET MVC request. If the request The request then falls down to the classic ASP.NET machin- is recognized as an ASP.NET MVC request, it is processed via ery to be processed as usual in terms of a page handler. the appropriate controller. If the request URL doesn’t match any criteria set by the application, the request is processed as Otherwise, the URL routing module attempts to match the URL a classic Web Forms request. If, for some reason, the request of the request to any of the defined routes. If no match is found, cannot be served, an error page is displayed. the request will be served by the standard ASP.NET runtime.

A couple of facts emerge from this brief discussion. Only requests that the routing module selects based on route You don’t need to add any special configuration to the ASP data are allowed to enjoy the ASP.NET MVC processing .NET runtime environment to run a Web Forms application. engine. As in Figure 2, all ASP.NET MVC requests are routed Special configuration settings must be made to the ASP.NET to a common HTTP handler that will instantiate a controller runtime environment if you want to run an ASP.NET MVC class and invoke a defined method on it. Next, the controller application. Put another way, you can’t host ASP.NET MVC method selects a view object to generate the actual response. pages in a Web Forms application. However, you can drop an ASPX page into an existing ASP.NET MVC application The URL routing module employs a number of rules when and successfully invoke it. trying to match an incoming request URL to a defined route. The most important rule is that routes are checked in The HTTP module that makes the difference between ASP the order they were registered in global.asax: .NET Web Forms and ASP.NET MVC is the routing module. protected void Application_Start() Here’s the script you need: { RegisterRoutes(RouteTable.Routes); } public static void RegisterRoutes(RouteCollection routes) : { "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } ); If your application runs in Integrated mode, the same script // Second route : must also be added under the sec- // Third route : tion. The effect of the routing module and the different fate }

DevConnections | November 2009 19 CoreCoder A Runtime Environment for Two

"Default", To ensure that routes are processed in the right order, you "{controller}.mvc/{action}/{id}", must list them from the most specific to the least specific. new { action = "Index", id = "" } ); In any case, keep in mind that the search for a matching // Handle requests for the application’s root route always ends at the first match. This means that add- routes.MapRoute( ing a new route at the bottom of the list may not work and "Root", "", may also cause you a bit of trouble. new { controller = "Home", action = "Index", id = "" } ); } The routing module decides whether a given request will be handled by Web Forms or by ASP.NET MVC. However, the routing module is allowed to kick in only if the request With these changes in place, the application can handle URLs has been already recognized as an ASP.NET request. This where the controller name is trailed by the .mvc extension. recognition can happen only at the IIS level; details depend on the working mode of IIS. /customers.mvc/edit/alfki

Configuration for IIS 6.0 and IIS 7.0 The URL is a bit less clean and elegant because of the .mvc Let’s first consider an ASP.NET application configured to extension, but at least IIS can route it correctly to ASP.NET run in IIS 7.0 integrated pipeline mode. If it’s a Web Forms MVC. To make the .mvc extension known to IIS, though, application, then all its URLs have an extension that IIS you need to register it. As an alternative, you can use other knows how to handle. If you use a custom extension, it’s extensions that are already known to IIS as handled by your responsibility to ensure that the extension is mapped ASP.NET; for example, *.aspx or *.axd. to the ASP.NET extension module in IIS. URLs managed within an ASP.NET MVC application are, instead, exten- A wildcard script map is another option to route any sionless. How can you route them to ASP.NET first so that incoming request to ASP.NET and subsequently to the the routing module can be involved? configured routing module. A wildcard script map, though, may affect application performance negatively. In the IIS 7.0 Integrated pipeline mode, any requests go through a sequence of events that registered HTTP modules Adding Web Forms Pages can intercept. By registering the URL routing module as a Because ASP.NET Web Forms pages are clearly based on web server HTTP module, you enable it to put hands on disk files, the URL routing system will let them pass and the request as it arrives at the gate. In IIS 7.0 Integrated doesn’t route them to the ASP.NET MVC runtime environ- mode, therefore, there’s no need to route requests to ASP ment. This ensures that an ASP.NET MVC application can .NET to trigger the URL routing HTTP module. serve both types of resources.

Things are a bit different in IIS 6.0 and in IIS 7.0 Classic I recommend that you create a folder in your project and group mode. With these versions of IIS, the ASP.NET runtime your .aspx pages below it. These Web Forms pages live in a environment is not fused to the IIS environment. Sub- separate world and obey only the well-known rules of classic sequently, an explicit step is required that forwards the ASP.NET programming. In a way, it’s like having a separate request to the ASP.NET runtime so that the routing module Web Forms project within the root ASP.NET MVC project. can be triggered. Without an explicit forward, IIS will be left to deal with an extensionless URL. IIS would assume An ASP.NET MVC page can link a Web Forms page and that you’re making a request for a virtual directory within vice versa. However, no automation can be employed, and the application. As a result, the request never reaches the to exchange parameters, you need to resort to intrinsic routing system; at the same time, though, it can’t be served objects such as Request, Cache, or Session. by IIS as well because no such virtual path may exist. An HTTP 404 error is inevitable. There are two ways to solve A Shared Architecture the routing issue. You can modify the route table to use file ASP.NET Web Forms and ASP.NET MVC are two faces extensions, or you can use a wildcard script map. of the same coin. Improvements on ASP.NET MVC don’t necessarily mean that resources are being subtracted from The easiest way to get ASP.NET routing to work with older Web Forms development. The fact that the two frameworks versions and legacy configurations of IIS is to modify the share the same runtime environment is yet more evidence route table in global.asax, as shown below. of the strict bond between the two. public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); Dino Esposito, an architect at IDesign, specializes mainly in ASP // Add a .mvc extension to the URL routes.MapRoute( .NET, AJAX and, RIA solutions.

20 November 2009 | www.DevProConnections.com

FederatedSecurity By Michele Leroux Bustamante A Crash Course in Windows Identity Foundation Add federated and claims-based security to .NET Framework apps

laims-based and federated security scenarios are gain- ing wider popularity as platform tools evolve to sim- Author’s note In this new column, I’ll explore claims-based and plify the developer experience in this space. Adopting a C federated security scenarios for your ASP.NET and claims-based and federated security model is beneficial to WCF and ASP.NET applications for many reasons. Claims-based Windows Communication Foundation (WCF) appli- security decouples applications from the mode of authentica- cations using Windows Identity Foundation (WIF). tion so that they aren’t impacted if credential requirements This first installment will provide an overview of change or if new types are supported; it also provides a more core WIF features and review both active and pas- flexible and more granular artifact for authorization. And sive federation scenarios. This broad introduction most important, claims-based security supports federated will provide those new to WIF a point of reference security models. The primary value proposition of a feder- for future installments to the column that dive into ated security model is so that applications can grant access practical implementation details. Feel free to send to users who authenticate to another domain. This reduces any questions you’d like to see answered in the IT overhead associated with provisioning and de-provisioning column to [email protected]. users, reduces the potential for errors from managing duplicate accounts across applications and domains, and makes it possi- ble to safely establish trust relationships between applications, departments, or even between corporate entities.

Assuming you understand the value proposition, this article will briefly introduce federated security concepts followed by a whirlwind tour of WIF features for WCF and ASP.NET. I’ll walk through the participants and flow of communication for both active and passive federation while explaining the basic requirements to set up each scenario with WIF. The discus- sions will also include a very high-level explanation building an active or passive security token service (STS) with WIF.

Federated Security 101 Let’s start with a brief introduction to federated security. Figure 1 shows what a federated security scenario looks like and the participants in the scenario, from a very high level. • The subject is the party that will be granted access to an application. This is usually the end user interacting with a client application or a web application via the browser. • The requestor is the agent (the client application or browser) requesting the security token that will describe Figure 1: Federation participants and communication flow the subject.

22 November 2009 | www.DevProConnections.com • The relying party (RP) can be a web application (ASP less code to implement claims-based and federated security .NET) or service (WCF) that will authorize access to fea- scenarios. Though not an exhaustive list, here are some tures and functionality based on the claims presented in examples of things that you can do with WIF: a security token. This token must be from a trusted token • Replace classic WCF security behaviors with a new, more issuer. flexible mechanism for authenticating and authorizing • The identity provider (IdP) is responsible for authenticat- calls. You can do this even if you are not working with ing the subject. This implies that it has a credential store federated security. in its domain (e.g., Active Directory or a custom creden- • Implement a claims-based security model for WCF ser- tials database). vices that integrates well with classic .NET Framework • The STS is responsible for issuing a security token for role-based security techniques. the subject. If the STS is located at the IdP, it will likely • Likewise, implement claims-based ASP.NET applications issue a security token that carries identity claims for the that can leverage classic role-based security techniques Subject. The STS may also issue other claims relevant to including existing ASP.NET login controls. authorization at the RP. • Support passive federation in your ASP.NET applications. • The security token format can vary per scenario; how- • Implement a custom STS to meet requirements not satis- ever, Security Assertion Markup Language (SAML) is a fied by an existing STS platform such as Active Directory very popular token format for federation. SAML is an Federation Services (ADFS). Building a fully functional interoperable, XML-based security token format that custom STS is a lot of work and thus should be a last carries SAML assertions (claims) in a secure manner in resort. that the issuing STS digitally signs the token and usually • Issue managed information cards from the STS, to sup- encrypts it for the RP. port identity selection from CardSpace. • Support information card selection from ASP.NET appli- A trust relationship must exist between the RP and the STS. cations. The STS won’t issue tokens for any RP it doesn’t have knowl- edge of. The RP won’t accept tokens from an STS it doesn’t Within each of these topics, of course, there are implemen- trust. The RP indicates its required claims; the requestor calls tation details that can vary. Thus, they will be worthy of the STS requesting a security token for the subject passing the discussion in future installments to this column. For now, RP’s requirements and credentials for the subject; the STS (at back to the crash course in WIF! the IdP) authenticates the subject, gathers identity and other relevant claims, and issues a security token carrying those Active Federation with WIF claims; the requestor passes that token to the RP for authori- Active federation involves a client application (requestor), zation; the RP verifies that the token is from a trusted issuer, a (the RP), and an STS for token issuance (this then authorizes access based on the claims within. could be part of the IdP). Figure 2 illustrates a simple active federation scenario involving a single STS. In this case, the This flow of communication is based on the WS-Trust proto- col (see docs.oasis-open.org/ws-sx/ws-trust/200512/ws-trust- 1.3-os.). The requestor passes a Request for Security Token (RST) to the STS according to this specification, and the STS replies with a Request for Security Token Response (RSTR). WS-Federation (see www.oasis-open.org/commit tees/tc_home.php?wg_abbrev=wsfed) supplies two profiles for federation with WS-Trust: the Active Requestor Profile (the rich client and web service scenario) and the Passive Requestor Profile (the browser and web application scenario). With the help of WIF applications built with the .NET Frame- work, you can implement scenarios based on these protocols.

Windows Identity Foundation WIF is the new identity model framework for the .NET Framework. It provides the features necessary to build claims-based applications and services, for supporting active and passive federated security scenarios, and for building custom STS implementations as needed, and it has built-in support for information cards (for scenarios that Figure 2: Active federation with WCF and WIF involve Windows CardSpace). With WIF you write a lot

DevConnections | November 2009 23 FederatedSecurity Windows Identity Foundation

located, so that the client can generate a federated proxy. In addition to the federated endpoint, the service is configured for WIF with the figuration> behavior. This behavior and IdentityModelServiceAuthoriza- ServiceCredentials and ServiceAutho- rizationManager. These WIF compo- nents (among others) supply a new mechanism for processing incoming security tokens and authorizing calls to the service. They rely on a special configuration section, .identityModel>, to initialize the WIF runtime. Figure 4 shows the funda- mental settings you should provide for Figure 3: Service model settings to expose a federated endpoint with WIF enabled a WCF service.

The in Figure 4 lists a single trusted certificate indi- matching the thumbprint must be People store. The result is that security tokens will be trusted only if they are signed by the matching private key for this certificate, which in this scenario 2) is trusted. The section by default expects you to pro- vide at least one accepted audience Figure 4: Sample identity model configuration for a WCF service Uniform Resource Identifier (URI). SAML tokens usually include an audi- WCF service at the RP exposes a federated endpoint; the ence constraint that indicates for whom the token is issued. STS exposes a WS-Trust endpoint; the client uses a WCF If this behavior is not disabled, the incoming token must proxy to authenticate to the STS endpoint and request a include a matching URI from this list to be valid. The security token, then passes the token with the first call to section indicates the certificate to the RP to establish a secure session for the user. be used to decrypt incoming tokens, assuming they are encrypted. These are the basic settings that you must pro- WIF Configuration for the WCF Service vide to initialize WIF for the RP service. There are some To set up the WCF service, you expose a federated endpoint other identity model settings that are quite useful to the and configure the service to use WIF. Figure 3 shows a pos- RP, and I’ll explore them in future columns, as the scenario sible configuration for the RPService from Figure 2. warrants.

The federated endpoint uses WS2007FederationHttpBinding, At this point, you have a WCF service ready for federa- which is based on WS-Trust 1.3 (the latest version of the tion. The client will generate a WCF proxy from the service standard). The binding configuration specifies the following: metadata based on this configuration and must provide the • which token format is expected, in this case SAML 1.1. appropriate ClientCredentials to authenticate to the STS. • which claims are required; in this case, a simple name WIF is not required at the client to implement active feder- claim is indicated. ation—although WIF does include some useful components • where the trusted issuer’s metadata exchange endpoint is for specific client implementations.

24 November 2009 | www.DevProConnections.com public class RPSTS : SecurityTokenService type in WIF and provide an { override for GetScope() and public RPSTS(SecurityTokenServiceConfiguration config) : base( config ) GetOutputClaimsIdentity(). {} • Supply a WCF endpoint for protected override Scope GetScope(IClaimsPrincipal principal, RequestSecurityToken request) the STS using one of the WS- { Trust contracts implemented Scope scope = new Scope(request.AppliesTo.Uri.AbsoluteUri); scope.EncryptingCredentials = this.GetCredentialsForAppliesTo(request.AppliesTo); by the base STS type. scope.SigningCredentials = new X509SigningCredentials(CertificateUtil.GetCertificate(StoreName.My, StoreLocation.LocalMachine, "CN=RPSTS")); Figure 5 shows a simple STS return scope; } implementation. The Get- Scope() override is respon- protected override IClaimsIdentity GetOutputClaimsIdentity(IClaimsPrincipal principal, RequestSecurityToken request, Scope scope) sible for validating that the { IClaimsIdentity claimsIdentity = new ClaimsIdentity(); request is for a trusted RP. If claimsIdentity.Claims.AddRange( so, you will supply the cer- CredentialStore.GetClaimsForUser(principal.Identity.Name)); tificate to be used for sign- return claimsIdentity; } ing the token (in this case, the STS private key) and // other supporting methods } the certificate to be used to Figure 5: Active STS implementation for the sample encrypt the token (the STS should know the RP certifi- Now that the service is ready for federation, how will you cate from the trust relationship). authorize access to operations and underlying features? If the service is only concerned that the user is authenticated at the The override for GetOutputClaimsIdentity() is given access to STS, establishing that the security token came from a trusted a security principal based on IClaimsPrincipal. This type con- issuer is sufficient. Most likely you’ll expect the STS to issue tains the claims granted the authenticated user, in this case a token carrying some claims useful for authorization, such based on the user’s Windows credentials. Before the token is as roles or permissions. WIF attaches an authenticated issued, you’ll usually convert these claims into a meaningful security principal to each request thread—in this case, a set of claims for the RP, by initializing a new ClaimsIdentity ClaimsPrincipal type, which is a wrapper for the collection of instance. For this example, the credential store returns rel- claims from the issued security token. Like any other security evant claims per authenticated user. You should take a look principal type that implements IPrincipal, ClaimsPrincipal at the code sample for additional details, but this sums up exposes an IsInRole() method that can be used to implement the core aspects of a simple STS implementation. access control. The service model configuration in Figure 6 shows how the if (!Thread.CurrentPrincipal. IsInRole("Admin")) sample STS from Figure 2 exposes a WS-Trust 1.3 endpoint throw new SecurityException("Access is denied."); using the synchronous version of the contract: IWSTrust- 13SyncContract. The binding is based on WS2007HttpBind- You can use the identity model configuration to indicate ing defaults, which means that the STS requires a Windows which claim type represents a "role" for IsInRole() calls— credential to authenticate calls. For this particular example, or you can write code to check that a specific set of claims the default identity model configuration will suffice—for are present in the ClaimsPrincipal instance. The former is a example, no need to override how incoming credentials are cleaner model and works as long as only one claim type is processed. used for access checks. Implementing an Active STS with WIF the scenario in Figure 2, I’ll briefly describe what has to be done to imple- ment a custom STS. Keep in mind, however, that in this short discussion I’m skipping a lot of detail for brevity. You can implement a very basic STS as follows: Figure 6: A simple WS-Trust endpoint configuration • Subclass the SecurityTokenService

DevConnections | November 2009 25 FederatedSecurity Windows Identity Foundation

session is established and a session cookie generated.

Passive federation still involves WS-Trust messaging in the form of an RST and RSTR, the latter of which includes the issued security token. The difference lies in that they’re sent as query strings and form parameters rather than as Simple Object Access Protocol (SOAP) messages. In the next sec- tions, I’ll review how the ASP.NET application is configured and review the passive STS implementation—again only from a very high level.

Enabling Passive Federation for ASP.NET WIF supplies two HTTP modules to support passive federa- tion: WSFederationAuthenticationModule (FAM) and Ses- sionAuthenticationModule. The FAM handles redirecting to the STS from the RP and handles processing the RSTR to extract the security token and install a ClaimsPrincipal for the request thread. The SessionAuthenticationModule Figure 7: Passive federation with ASP.NET and WIF manages the authentication session: generating the session security token, which contains the ClaimsPrincipal; writing Passive Federation with WIF it to cookie; managing the lifetime of the session cookie; Passive federation involves a browser (requestor), a web and rehydrating the ClaimsPrincipal from the cookie when application (the RP), and a passive STS for token issuance. it is present. To enable these two modules, add the code in Figure 7 illustrates a simple passive federation scenario Figure 8 to your section (for Microsoft IIS whereby the RP is an ASP.NET application that supports 6.x) and to your section (for IIS 7): passive federation, and the custom STS is also passive— meaning that it is browser based as opposed to a WCF ser- For the FAM to handle requests, you must set the authenti- vice implementation. When users browse to the RP, they are cation mode to None and deny anonymous users access to redirected to authenticate to the STS, then redirected back to the site: the RP once a token has been issued. At this point, a secure type="Microsoft.IdentityModel.Web.WSFederationAuthenticationModule, Microsoft.IdentityModel, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" preCondition="managedHandler" /> tialized by the identity model Figure 8: Code to enable WIF HTTP modules for passive federation configuration. You should at least supply the following settings: a list of trusted cer- tificate issuers, the allowed claim types for authorization, federation. The first three work as discussed for active federation, whereas the pas- sive federation configura- tion is specific to ASP.NET scenarios. Figure 9 shows an example of the identity passive site. In the sec- Figure 9: Sample identity model configuration for an ASP.NET application tion you must enable passive

26 November 2009 | www.DevProConnections.com redirect to achieve passive federation for your ASP.NET appli- The STS control processes incoming RST requests before cation. This tells the FAM to handle processing of incoming the page is loaded (during PreRender). The control is requests to the site and to redirect to the STS for all unau- associated with a custom STS implementation (like that thenticated calls. The issuer setting indicates the STS to redi- from Figure 5). This STS implementation programmati- rect to. The realm setting actually tells the issuer (as part of cally invokes the FAM to produce a ClaimsPrincipal for the the RST) for whom the token will be issued, and this should authenticated user after which the same overrides for Get- match one of the acceptable audience URI. When the RSTR is Scope() and GetOutputClaimsIdentity() are called, the latter returned to the application, the FAM processes this response of which is once again responsible for producing the actual and constructs a ClaimsPrincipal for the request thread. claims to be issued and included in the security token. The control then redirects back to the RP (the RST indicates the Once again, the ClaimsPrincipal is useful for access control. URL where the reply should be sent), passing the RSTR in a In the case of ASP.NET, the IsInRole() check is not only form POST parameter. At this point, the FAM does its magic useful for dynamic checks, but this method is also encap- to process the RSTR at the RP and install a ClaimsPrincipal sulated in most of the login controls. Feasibly, if you can for the request thread for authorization. select a particular claim type as the "role" claim type (this is configurable), you can continue to implement role-based The beauty of using this control to implement a passive security with your favorite techniques except that the role STS is that very little code is required—only that of the check becomes a claims check. custom STS, as discussed earlier. Of course, the downside is that you cannot customize much of the passive federation Implementing a Passive STS with WIF behavior beyond a few simple overrides before and after the A passive STS can be implemented in two ways with WIF: RST is processed. I’ll explore some deeper scenarios that using the FederatedPassiveTokenService control (STS con- require customization in future columns. trol) or using the FAM with the help of some additional custom code. For simplicity I will focus on the control More to Come implementation here. The architecture of this implementa- I hope you’ve enjoyed this whirlwind tour of federated tion looks as shown in Figure 10 (assuming that you’re security and WIF, in which I’ve set the foundation for using forms authentication to authenticate users prior to future installments of this new column. If you’re looking issuing tokens). for a deeper introduction to the WIF platform, you should download the WIF whitepaper from MSDN (I’ll provide When the FAM redirects from the RP to the STS, an RST is the latest link in the readme for the code download—see passed along with the request. In this case, the FormsAuthen- blurb below, since this is likely to change), which describes ticationModule will redirect to the login page passing the orig- additional WIF features. I also spent some time elaborat- inal request in the ReturnUrl query string parameter. In the ing on the value of claims-based and federated security in postback of the login page, the user is authenticated (using my Claims-Based WPF white paper, which you can find at the ASP.NET or your own custom code), then claimsbasedwpf.codeplex.com. redirected to the ReturnUrl, which is the original RST and pre- sumably targets a page that contains the STS control.

Michele Leroux Bustamante ([email protected]) is chief architect of IDesign, a Microsoft Regional Director for San Diego, and a Microsoft MVP for Connected Systems. Her latest book is Learning WCF (O’Reilly 2007, updated in 2008), and she blogs at www.dasblonde.net.

Figure 10: A passive STS implemented with the FederatedPassiveTokenService control Download the code for this article at www.dasblonde.net/ downloads/wifcolumn_Dec09.zip.

DevConnections | November 2009 27 MicrosoftInsider By Laurence Moroney

What’s New with the Microsoft Web Platform

elcome to Microsoft Insider, a new monthly col- Microsoft will help me install this to my server even if it’s umn that looks at what’s going on in Redmond written with a competing technology such as PHP?" The Wand how it affects you as a developer. This answer is a resounding YES. The Microsoft WPI makes it month we'll look at the Microsoft Web Platform and some easier for you to install and configure all of the above. exciting things going on with the group building this. Our goal for the Web Platform is to make it the best choice I first joined Microsoft in 2006, having come from an open when building web solutions or applications for your busi- source background. I’ve been stunned at how the company ness, regardless of size. Whether you’re a web professional is evolving and changing and how it's becoming more looking to increase your skills and offerings, a multinational open. Just a few years ago, nobody would have believed corporation looking to create your company’s global web that Microsoft would embrace PHP the way it has. Changes presence, or a small business looking for turnkey apps, to the Web Platform, including the just-released Web Plat- we’ve built the Microsoft Web Platform to work for you. form Installer (WPI) 2.0, are the cornerstone of this shift. You can learn more about it from www.microsoft.com/web.

Microsoft IIS—the web server—is just one component of From this site you can inspect the marketplace (launching the Web Platform, which includes the following: Fall 2009) and maybe even register your skills, find host- • the IIS web server ing partners, read the team blog for the latest news and • the OS underlying the web server: Windows Server 2008 announcements, and download the WPI, which provides • the frameworks for building web apps: .NET Framework a one-stop shop to allow you to install IIS, extensions to including ASP.NET, ASP.NET MVC, and ASP.NET AJAX IIS, the SQL Server database, Visual Web Developer, PHP, • services and products such as SQL Server 2008 or BizTalk applications built on .NET or PHP, and a whole lot more. It Server that support web applications provides a single wizard that allows you to install all these • tools for building web apps, such as Visual Studio and technologies easily. Expression • an ecosystem of prebuilt applications that provide a launch I recommend that you download the WPI and check out point for your web presence, such as blogging engines, con- the extensions, applications, and value-added tools such as tent management systems, or e-commerce engines the SQL Server Driver for PHP. Plus you should install the • a marketplace of web professionals to help you with your SEO toolkit, which alone is worth the download, and for needs which you can find a tutorial on the team blog at www • website enhancements, such as search engine optimiza- .microsoft.com/web. tion (SEO) tools • interoperability and support for industry standards as a So, this has been a quick look at the WPI and the new first-class citizen and the ability to use the tools or lan- Microsoft Web Platform. I urge you to go take a look and guage of your choice take a play—you’ll be amazed how much time and effort you can save by using the WPI to install and configure your You probably started reading through that list thinking that site and server and how quickly you can start building and it’s just another Microsoft sales pitch. I know I would. But, running a website cost-effectively. as you get to the end of the list, you might start seeing the real value. “‘An ecosystem of prebuilt applications’”? You mean I don’t need to go poking around the web wonder- Laurence Moroney ([email protected]) is a senior product ing where I can find an open source CMS app? You mean manager at Microsoft, working on the Web Platform.

28 November 2009 | www.DevProConnections.com

ExploringWCFServices By Zoiner Tejada

Windows Application Server Extensions Getting started with Beta 1 of Dublin for hosting .NET 4 WCF and WF services

o not be fooled by the word “Extensions” in Win- message-based activation of hosted services and so requires dows Application Server Extensions (code-named that IIS 7.0 and the IIS 7.0 Administration Pack (which DDublin). The enhancements that Dublin adds to the provides UI editing of ASP.NET configs within IIS Manager) combination of Microsoft IIS 7, Windows Process Activation be installed. Dublin also requires that the .NET Framework Service (WAS), and .NET Framework 4.0 provide the much 4 be installed—in fact, Dublin’s management features only longed-for standard host for Windows Workflow Founda- support .NET 4–based WF and WCF services. Microsoft tion (WF) and Windows Communication Foundation (WCF) .NET 3.5 apps will need to be migrated to leverage the services. The goal of “Dublin” is to simplify the management new functionality. Windows PowerShell V2 is also required of services and to add capabilities to the core services host because PowerShell cmdlets are central to Dublin’s manage- (WAS) so that services can be inherently resilient and scal- ment and monitoring functionality (as we’ll see momen- able. tarily). Monitoring and workflow instance persistence data are stored in a SQL Server database, so at minimum SQL The management aspects of Dublin consist of about a Server 2008 Express is required. Finally, for development dozen UIs in the form of IIS Manager Extensions and Dublin purposes, one needs Visual Studio 2010. PowerShell cmdlets that deliver a centralized configuration and monitoring experience for WF and WCF services. For Let us now briefly examine what it takes to install Dublin. resilience and scale, Dublin has features that support and After downloading and running AseSetup, you’ll be pre- enhance the availability, reliability, and scalability of hosted sented with a wizard that allows you to control the feature services: high-performance event tracing, instance restart, selection and, most importantly, configure Dublin’s persis- lock retry, and autostart as well as a configurable response to tence and monitoring stores. That’s all there is to installing unhandled exceptions in workflow services. Dublin using the UI approach; it’s quite an easy process.

In this article, I'll provide a quick overview of the Dublin Service Deployment installation process, then show Dublin features in action as Now that you’ve installed Dublin, let’s assume you have a they support service deployment, post-deployment configu- workflow service developed, and you want to deploy and ration, monitoring, and control. install the service and its configuration into Dublin. (For guidance on how to build such a workflow service, see Dublin Installation and Configuration "Introducing .NET 4.0 Workflow Services," asp.netPRO Sep- Dublin is available as a web download that consists of a single tember 2009.) The deployment scenario in Dublin leverages 5MB executable, AseSetup.exe. Much of the functionality that MS Deploy client components and synchronization agents Dublin exposes or enhances is ultimately provided by other and adds a plug-in to IIS Manager, which provides UI sup- features of Windows or the .NET Framework. For this reason, port for package import and export. To initially get your it is important to understand the Dublin prerequisites. To begin workflow service from Visual Studio installed in Dublin, with, Dublin will run only on Windows 7, Windows Vista, within Visual Studio 2010 go to the Project Properties and Windows Server 2008, or Server 2008 R2. In addition, the auto- click the Package/Publish tab, as Figure 1 shows. start feature requires the autostart service-activation functional- ity that’s available only in Windows 7 or Server 2008 R2. Ensure that Create MSDeploy package as a ZIP file is checked Dublin builds upon the hosting feature set of IIS and WAS’s and save your project. Next, in Solution Explorer, right-click

30 November 2009 | www.DevProConnections.com your project, and choose Package, Create Package, as Figure 2 shows. The .zip file representing your package will be the package location specified on the Package/Publish tab.

Now, on your Dublin box open IIS Manager and click a website to import your application into IIS Manager (or cre- ate a new website—just make sure it is configured with a .NET 4 AppPool). In the Actions pane, under Manage Pack- ages, choose Import Application, as Figure 3 shows.

In the dialog box that appears, browse to your package .zip file, click Next and Next again. You’ll then see a window, which Figure 4 shows, that lets you name the import location and, effectively, the application as well. Enter an appropriate value Figure 1: Configuring MS Deploy package settings and click Next, then click Finish. Your package should now appear as an application under the selected website. at the selected scope. Figure 6 shows the dialog box that Exporting an application from IIS Manager is equally trivial. appears at the Server scope. Note that the Configure option Basically, select your application in the Connections pane, is also available by right-clicking a node in the Connections choose Export Application from the Actions pane (Figure 3), pane and selecting .NET 4 WF and WCF, Configure. and step through the wizard. The end result will be a package like the one created by Visual Studio. This process lets you cap- The following is a listing of all the configuration-related IIS ture changes you might make post-development in a form that Manager Extensions, to give you a feel for just how much can later be redistributed to production servers or other servers Dublin enables you to configure through the IIS Manager UI: in a web farm. Note that currently no automated process for • Endpoints: listing of endpoints and configuration of end- synchronizing all nodes in the farm exists—you must manually point address. import packages to each node. • Services: listing of services, configure monitoring, persis- tence, autostart, throttling, certificates and endpoints for Service Configuration a selected service. Dublin setup provides many defaults in the root web.config • Website: configure monitoring, persistence, throttling and available to all child sites and applications. These settings certificates for a website. are overrideable in the web.configs of the latter. The config- • Application: configure monitoring, persistence, autostart, uration of services hosted in Dublin amounts to the editing throttling, and certificates for a web application. of settings defined in this hierarchy of configuration files • Persistence database: manage connection strings and ini- and can be accomplished in one of two ways: graphically tialize a persistence database. by using the IIS Manager Extensions or at the command • Monitoring database: manage connection strings and ini- line via Dublin PowerShell cmdlets. tialize a monitoring database. • System Services: allows you to configure the accounts IIS Manager extensions. Dublin adds many new screens to used by the Event Tracing for Windows (ETW) Event IIS that provide interfaces for performing WCF configuration Collector and Workflow Management Services, as well as editing. These extensions make editing much simpler than modify the default Event Collector settings. using SvcConfigEditor and ensure that configuration is cor- rectly scoped to the server, site, application, and service levels, Many of the aforementioned listings let you navigate depending on what is currently selected in IIS Manager. In between related entities. For instance, with a service addition, these extensions provide functionality for features selected, you can navigate to its related endpoints and con- that previously had no editor, such a configuration of SQL Per- figure them as well as vice versa. sistence for workflows. Most of these are visible in the center panel of IIS Manager, grouped under the Application Server Dublin PowerShell cmdlets. PowerShell cmdlets are at the Extensions for .NET 4 header. Figure 5 shows the options heart of Dublin, providing the functionality for controlling, available at the Server scope (Dashboard, Endpoints, Monitor- querying, and configuring service instances, services, appli- ing DB, Persistence DB, Services, and System Services). cations, and servers. All IIS Manager Extensions ultimately In addition to the options available in the center pane, the call through to the Dublin cmdlets. It’s useful to think of Actions pane on the right includes a .NET WF and WCF sec- there being three categories of cmdlets in Dublin: tion that has one hyperlink: Configure. This link will display • Service Management cmdlets: act on the configuration of a context-sensitive dialog box for configuring .NET 4 features services and configuration as well as control of service

DevConnections | November 2009 31 Exploring WCF Services Windows Application Server Extensions

Figure 2: Creating a deployment package

instances. These cmdlets will include the term “ser- vice” or "instance" in their Figure 5: IIS Manager showing some Dublin extensions name. • Application Management Instance. cmdlets: configure and list To run Dublin cmdlets, you’ll need to load PowerShell V2, applications. These will then import the single module Microsoft.ApplicationServer include the term “applica- .Management.dll. For example, to view all registered con- tion” in their name. nection strings in the default website, you would run the • Server Management following two commands: cmdlets: configure the Import-Module ApplicationServer\Microsoft.ApplicationServer persistence and monitor- .Management.dll ing databases as well as Get-ASConnectionString "Default Web Site" the ETW Event Collector and Workflow Manage- The commands’ output will be similar to that in Figure 8. ment Service system ser- vices. These will include Finally, it’s worth noting that Dublin ships with support for the term “database” or remote management from both PowerShell cmdlets and IIS “event collector” in their Manager. In IIS Manager’s case, the IIS Web Management name. NT service is required. In the case of remote cmdlets, the Windows Remote Management Service must be running. Figure 7 summarizes all the Dublin cmdlets; the full Service Monitoring and Control name of the cmdlet is the Dublin functionality extends into the area of controlling result of combining a verb, applications, services, and service instances as well as a dash, and a noun—for monitoring the state of service instances, supporting drill Figure 3: Actions pane example, Get-ASAppService- down into tracked events for a service instance, and custom querying of the monitoring store through the IIS Manager Extensions and Dublin cmdlets. The control features let you resume, suspend, terminate, cancel, and delete a workflow service instance. These controls are often used in combi- nation. For example, one might use the dashboard to drill down into a suspended workflow instance and resume it. Or, one might query for an active workflow instance with a specific variable value and suspend it. (For more informa- tion about Dublin monitoring, see “Monitoring and Trouble- shooting .NET 4 Services,” asp.netPRO November 2009.)

Robust Hosting Functionality Beyond the configuration and monitoring experience pro- vided by the IIS Manager Extensions and cmdlets, Dublin also provides some features that themselves provide for more robust hosting. We’ve mentioned two of these in Figure 4: Import package location naming passing and will now explore what they offer.

32 November 2009 | www.DevProConnections.com that are configured to use persistence. WMS, control func- tions in IIS Manager Extensions, and the Dublin cmdlets all communicate with the endpoint via named pipes and use the endpoint to resume, suspend, cancel, or terminate a workflow service instance.

SQL Workflow Instance Store. The SQL Workflow Instance Store is provided by Dublin, unlike previous versions of the .NET Framework, which included a SQL Persistence Pro- vider out of the box. Used in process by the workflow ser- vice host, the sqlWorkflowInstanceStore class implements the persistence provider functionality that loads from and saves workflow instances to a SQL Server 2008 database. The majority of features enabled by this class are illustrated by the Advanced Persistence Settings in the service configu- Figure 6: Configuration at the server scope ration, as Figure 9 shows.

The first feature is lock retry (shown in the screen as Action Workflow Management Service (WMS). The first of these on instance lock exception). This handles the condition that is WMS, which is installed by default as a Windows service can result when multiple serviceHosts are attempting to named Application Server Workflow Management Service. resume the same service instance from persistence. Without WMS is the workhorse process for many of Dublin’s work- lock retry, an InstanceLockedException would be thrown flow features. When a host crashes while executing a ser- and the operation would immediately fail. Lock retry offers vice instance, that instance is abandoned. WMS monitors two different approaches to the retry interval: one that for these abandoned instances and resumes their execution retries in a linear fashion and another that retries in inter- starting from their last persistence point. In addition, WMS vals that grow exponentially where the initial interval is restarts workflows persisted after a graceful shutdown of very short, but grows quickly. Only when the number of those whose durable timers have expired (e.g., resulting retries is exceeded is the InstanceLockedException thrown. from a delay activity whose duration has elapsed). Dublin also transparently introduces an internal endpoint, The next is unhandled exceptions. This is behavior configured called the Instance Control Endpoint (ICE), for workflows on the service that instructs the SQL Workflow Instance Store what to do when a service instance encounters an unhan- Noun Supported Verbs dled exception. The options are to abandon (discarding in ASAppServiceInstance Get, Remove, Resume memory state and rolling back to the last persisted state; can ASAppMessageLogging Get, Set, Disable, Enable be automatically recovered by the WMS); abandon and sus- ASConnectionString Add, Remove, Get, Set pend (rolls back to last persist point but waits for an explicit ASAppMonitoring Get, Set, Start, Stop resume); terminate (forces completion of the workflow; it ASAppDebugTracing Get, Set, Disable, Enable ASApplication Get, Set, Start, Stop cannot be resumed later); and cancel (completing the work- ASAppServiceTracking Clear, Get, Set flow but allowing cancellation handlers defined in the work- ASAppServiceTrackingProfile Get, Import, Remove flow to execute and thereby close the instance gracefully). ASAppServiceThrottling Clear, Get, Set ASAppServicePersistence Clear, Get, Set The functionality for unload on and persist on idle ASInstanceExceptionPolicy Clear, Get, Set ASMonitoringDatabase Clear, Initialize, Remove have been decoupled in .NET 4, enabling you to configure ASMonitoringDatabaseArchiveConfiguration Get, Set, Remove a workflow service instance to persist on idle but keep it ASAppAnalyticTracing Clear, Get, Set loaded in memory. This is useful for checkpoint workflow ASAppServiceCertificate Clear, Get, Set execution, such that if the host later crashes, the workflow ASInstanceUnloadPolicy Clear, Get, Set can be resumed from this latest persistence point. ASAppServiceAutoStart Disable, Enable, Set ASAppServiceBehaviorName Get, Set ASAppPerformanceCounter Get, Set Workflow state in its serialized form can get fairly large. ASAppServiceEndpoint Get, Set To address this issue, you can now compress state data by ASAppServiceEndpointTransportQuota Get, Set using GZip in persistence store, via the Encode instances ASPersistenceDatabase Initialize, Remove option. Also, one can now elect to keep instance state data ASAppServiceEndpointAuthentication Get ASAppService Get after the workflow instance completion (ordinarily, the state Figure 7: Dublin cmdlets of completed instances would be purged upon completion).

DevConnections | November 2009 33 Exploring WCF Services Windows Application Server Extensions

Name : DefaultApplicationServerExtensions ConnectionString : Data Source=localhost\SQLEXPRESS;Initial Zoiner Tejada ([email protected]) is passion- Catalog=ApplicationServerExtensions;Integrated Security=True ProviderName : System.Data.SqlClient ate about workflows and the future of implementing IsLocallyStored : False connected systems with them. He’s the chief software SqlConnectionStringBuilder : {[Data Source, localhost\SQLEXPRESS]... Server : localhost\SQLEXPRESS architect at Hershey Technologies, is recognized as a Database : ApplicationServerExtensions Microsoft Industry Influencer, and is an advisor to Figure 8: Output of a Dublin PowerShell cmdlet Microsoft’s Connected Systems Division. Zoiner has a degree in computer science from Stanford University Application Server Event Collector. The last major feature is and blogs at TheWorkflowElement.com. the Application Server Event Collector. This provides a high- performance, low-overhead mechanism for collecting ETW traces and writing them to the Dublin monitoring database.

Extensive Extensions I’ve attempted to show you just how compelling the "exten- sions" provided by Dublin are. These Windows Application Server Extensions effectively pull together a lot of services- related functionality and make it manageable from one cen- tral location. These extensions for services and workflows, together with the existing Web Platform and application server capabilities, provide a compelling general-purpose platform to build, run, and manage distributed applications on Windows Server.

Figure 9: Advanced workflow persistence settings Find Out More Learn more about Windows Application Server Extensions (aka “Dublin”): Tech*ED 2009 Sample Code - A Day of WCF + WF + “Dublin” Precon “Introducing .NET 4.0 Workflow Services,” Files from pre-conference seminar presented by asp.netPRO, September 2009 Zoiner Tejada and Michele Leroux Bustamante www.theworkflowelement.com/2009/05/teched-2009- “What’s New in WCF 4.0?” asp.netPRO, April 2009 sample-code-a-day-of-wcf-wf-dublin-precon.html? cid=6a00d8354da76369e201157043d38c970c Overview of WCF 4.0, WF 4.0, and Windows Server “Dublin” technologies Microsoft Developer Platform Application Tier Develop- download.microsoft.com/download/5/9/ ment—Conversation with Burley Kawasaki (blog post) B/59B74A2A-245D-4304-802E-E0A0800FACD3/ community.devproconnections.com/blogs/windows Dublin__NET_4_overview.docx devpro/archive/2009/02/05/microsoft-developer- platform-application-tier-development-conversation- “Dublin”: Hosting and Managing Workflows and Ser- with-burley-kawasaki.aspx vices in Windows Application Server (video) channel9.msdn.com/pdc2008/BB18 Hosting a WF 4.0 workflow service in “Dublin” (blog post) endpoint.tv – WCF and WF 4.0 First Look with Zoiner geekswithblogs.net/bloesgen/archive/2009/02/10/ Tejada (video) hosting-a-wf-4.0-workflow-service-in- channel9.msdn.com/shows/Endpoint/endpointtv- ldquodublinrdquo.aspx WCF-and-WF-40-First-Look-with-Zoiner-Tejada Ron Jacobs: WF/WCF 4 and “Dublin” Resources Sessions on WCF, WF, and Dublin at Fall 2009 blogs.msdn.com/rjacobs/archive/2009/06/02/wf-wcf- DevConnections, 4-and-dublin-resources.aspx devconnections.com

34 November 2009 | www.DevProConnections.com

Silverlight101 By Dan Wahlin Collecting Data with Silverlight’s DataForm Control Bind, define, and access end-user data

ollecting data from users is a common requirement From there you can create in enterprise applications and is something that can a new Silverlight project C be done in a variety of ways using Silverlight 3. and drag the DataForm con- Custom forms can be created using built-in data entry con- trol from the toolbox into trols, such as Textbox and ComboBox, and arranged using your XAML file to have the layout controls, such as Grid and StackPanel. appropriate namespace and assembly reference added Silverlight 3 introduces a new control called the DataForm automatically. Figure 2 that simplifies the process of collecting data while allow- shows the namespace prefix ing multiple records to be navigated, displayed, edited, and control definition added and deleted more easily. By using the DataForm control, in the XAML file. you can also minimize the amount of layout code that has to be written, plus handle validation of data entry fields. The DataFormToolkit This article is the first in a multipart series covering the namespace prefix identi- DataForm control and the different features it offers. I’ll fies the assembly and introduce the DataForm and explain different ways data can namespace for the control be bound to it, and future articles will dive into additional and defines the DataForm details. Let’s start things off by looking at where you can control within the XAML. If get the DataForm control and how it can be used in a you look in your project ref- Silverlight application. erences, you’ll also see that a reference to the System Getting Started with the DataForm Control .Windows.Controls.Data The DataForm control is part of the Silverlight 3 Toolkit .DataForm.Toolkit assembly (available at www.codeplex.com/Silverlight) and contains has been added. several rich controls to enhance Silverlight applications. It’s similar to ASP.NET’s DetailsView control in some Binding Data to the regards but adds additional features to simplify data DataForm Control Figure 1: New controls in the collection. Key features of the DataForm control include If you run the Silverlight Silverlight Toolkit the ability to autogenerate fields; handle control layout; allow users to navigate through multiple fields.

After downloading and installing the Silverlight 3 Toolkit, you’ll see several new controls appear in your Visual Studio toolbox, including the Data- Figure 2: Addition of appropriate namespace and assembly reference Form, as Figure 1 shows.

36 November 2009 | www.DevProConnections.com instantiating the object, then assigning it to the DataForm’s public class Customer { CurrentItem property: public int CustomerID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } CustomerDataForm.CurrentItem = custObject; public int Age { get; set; } public Address Address { get; set; } } public class Address A collection of Customer objects can also be bound to the { control as well, using its ItemsSource property: public string Street { get; set; } public string City { get; set; } public string State { get; set; } CustomerDataForm.ItemsSource = custObjects;

public int Zip { get; set; } } Although creating and binding objects to the CurrentItem Figure 3: Customer class bound to the DataForm control and ItemsSource properties can be done directly in the XAML’s code-behind file within the Loaded event han- project at this point, you won’t be too impressed, since a dler, it’s better to break this type of functionality out into blank white screen will be shown. Like any data-bound con- a separate class called a ViewModel. The term “View- trol, the DataForm has to have data assigned to it in order for Model” comes from a popular pattern called Model View it to display anything. This can be done by creating an object View-Model (MVVM) that defines how XAML can interact and then binding it to the control’s CurrentItem property. with other objects and how data can be bound to con- Figure 3 shows Customer and Address classes that will be trols defined in XAML. Although a complete discussion of bound to the control. MVVM is outside the scope of this article, by leveraging this pattern you can keep your data access and rules outside of Binding a Customer object to the DataForm is as simple as the XAML code-behind file to allow for better testing, better reuse, and more maintainable code. My public class MainPageViewModel company uses the MVVM pattern with client { public List Customers { get; set; } projects and has found it to be very helpful, public Customer CurrentCustomer { get; set; } especially when it comes to data binding. I’ll public MainPageViewModel() save a more complete discussion of MVVM for a { //Call out to data access layer here. We'll keep it future article. //simple for demo purposes and create sample objects directly Customers = new List { In the interest of following best practices defined new Customer { in the MVVM pattern, you’ll want to create a CustomerID = 1, Age = 50, FirstName = "Dave", LastName = "James", ViewModel class that can be bound to the Sil- Address = new Address {City = "Chandler", State = "AZ", verlight user control that contains the DataForm. Street = "1234 AnyStreet", Zip=12345} }, To do that, you can create a ViewModel class new Customer { named MainPageViewModel that defines a Cus- CustomerID = 1, Age = 50, FirstName = "Gina", tomers property and a CurrentCustomer property, LastName = "James", Address = new Address {City = "Chandler", State = "AZ", then create sample data within the class’s con- Street = "1234 AnyStreet", Zip=12345} } structor, as Figure 4 shows. }; this.CurrentCustomer = Customers[0]; } Although this is a simple example of a View- } Model class, the creation of data objects is being Figure 4: Creating a ViewModel class that can be bound to XAML done outside of the XAML code-behind file, which is the main point. This same approach

Now that once the ViewModel class is defined, you can reference it within the XAML file and bind it without writing a single line of C# or VB code. To bind the ViewModel class to the user control (and ultimately get data into the DataForm control), the ViewModel object can be Figure 5: Defining the ViewModel class that will be bound to the user defined within the user control’s resources sec- control and DataForm tion, as Figure 5 shows.

DevConnections | November 2009 37 Silverlight 101 DataForm Control

Customers and CurrentCustomer properties to the will result in the DataForm loading and showing one customer at a time, as Figure 7 shows. Figure 6: Binding ViewModel properties to the DataForm control At the top of the control, navigation controls and Since the ViewModel class is in the same project as the the Add and Delete icons (+ and – symbols) are displayed. XAML file, we only have to reference the namespace. If you Below this the Customer object properties are displayed. store your ViewModel classes in a separate project (which These buttons can be shown or hidden by setting the Data- I do for “real world” applications), you’d need to reference Form’s CommandButtonsVisibility property to one of the the assembly and namespace. values shown in Figure 8.

Once the namespace and associated prefix (vm in this As with ASP.NET controls such as GridView and DetailsView, example) are defined, the prefix can be used in the the DataForm control can automatically generate fields based Resources section of the XAML to define the ViewModel upon the object type being bound to it. Its AutoGenerate- class, as Figure 5 shows. You’ll also need to give the View- Fields property is set to true by default. This works well in Model resource a key so that it can be referenced. Now many situations, but even in this simple situation you can that the ViewModel is available as resource within the user see that the Address field shown in Figure 7 wasn’t displayed control, you can assign it to the DataContext using the fol- correctly since it’s a complex type. Let’s look at how we can lowing XAML code (notice that the ViewModel key is used customize what’s shown by the DataForm. in the data-binding syntax): Defining Custom DataForm Fields The DataForm control provides a way to define custom fields that allows you as a developer to have complete con- trol over what data input controls show. This is useful in Any data assigned to the layout root’s DataContext is more real-world situations where the form may have a vari- automatically available at runtime to all child controls, ety of controls that the DataForm doesn’t emit automati- including the DataForm. Figure 6 shows how to bind the cally when its AutoGenerateFields property is set to true.

Figure 7: DataForm control in action

Figure 8: CommandButtonsVisibility values Figure 9: Defining custom fields using the DataForm’s EditTemplate

38 November 2009 | www.DevProConnections.com public partial class MainPage : UserControl { MainPageViewModel _ViewModel; public MainPage() { InitializeComponent(); this.Loaded += new RoutedEventHandler(MainPage_Loaded); }

void MainPage_Loaded(object sender, RoutedEventArgs e) { _ViewModel = this.Resources["ViewModel"] as MainPageViewModel; _ViewModel.CustomerUpdated += new EventHandler( _ViewModel_CustomerUpdated); }

void _ViewModel_CustomerUpdated(object sender, CustomerUpdatedEventArgs e) { string msg; if (e.Status) { msg = e.CustomerName + " was updated!"; Figure 10: A DataForm with custom data fields } else { msg = "There was a problem updating the customer."; To create custom fields, you’ll want to set the } MessageBox.Show(msg); AutoGenerateFields property to false and then } define one or more templates as appropriate. private void CustomerDataForm_EditEnded(object sender, Built-in templates include EditTemplate (which is DataFormEditEndedEventArgs e) { used to control how a record is edited), NewIte- if (e.EditAction == DataFormEditAction.Commit) mTemplate (which is used to control what shows { _ViewModel.UpdateCustomer(); as new records are being added), and ReadOn- } } lyTemplate (which performs the rather obvious } task of showing a read-only version of the data). Figure 11: Updating Customer data by handling the DataForm’s EditEnded event For this example, I’ll focus on the EditTemplate and assume we’d like users to be able to modify data immediately as the form loads, rather than seeing read- DataForm control. Any changes made to the data will auto- only data first, then clicking an edit button to change the matically update the source object in the ViewModel, since data. Figure 9 shows an example of using the EditTemplate TwoWay bindings were defined. Being able to see the data along with the multiple DataFields. Notice that the data bind- is good, but you’ll want to be able to push any changes ing has been set to TwoWay for most of the controls and that made by the end user back to a WCF service or some other the binding syntax references the DataContext of the current type of service to save them to a database. record, which is the individual Customer object rather than the DataContext of the user control. As a user changes data in any of the data fields, the OK button will automatically be enabled by default. When OK Figure 10 shows what the DataForm looks like once the is clicked, two events fire—EditEnding and EditEnded. The Silverlight application is run. Although TextBoxes are used EditEnding event can be used to cancel an edit operation, here, fields such as State could easily be modified to show while the EditEnded lets you know if the edit operation has a ComboBox by doing something like the following: completed. Figure 11 shows how the EditEnded event can be handled in the XAML code-behind file and how a View- Looking through this code, you can see that when the EditEnded call is made a check is made to ensure the user didn’t cancel the edit operation. If the update was committed The list of states used in this example is being pulled from then the ViewModel’s UpdateCustomer method is called. a States property that was added in the ViewModel (the complete ViewModel class that includes the States property Note: There are several ways to call the ViewModel’s is available with this article’s code download). UpdateCustomer method, including using Silverlight behav- iors, events, third-party frameworks, and more. I’ve tried Accessing Data in a DataForm many of them and still find this solution to be the simplest You’ve seen how to bind data from a ViewModel object to a and easiest to manage. There are a lot of strong opinions on

DevConnections | November 2009 39 Instantly Search Terabytes of Text Silverlight 101 DataForm Control

◆ 25+ full-text and fielded data public class MainPageViewModel search options (with Unicode { support for hundreds of public List Customers { get; set; } international languages) public Customer CurrentCustomer { get; set; } public List States { get; set; } ◆ Built-in file parsers / public event EventHandler CustomerUpdated; converters highlight hits in public MainPageViewModel() popular file types { //Code ommitted for the sake of brevity ◆ Spider supports static and } dynamic web data; highlights public void UpdateCustomer() hits with links, formatting { and images intact //Call async service here in real app and callback would handle //raising event. We'll just simply raise the event to simulate ◆ API supports .NET, C++, Java, //the update occurring CustomerUpdatedEventArgs args = new CustomerUpdatedEventArgs SQL, etc. .NET Spider API { CustomerName = this.CurrentCustomer.FirstName + " " + this.CurrentCustomer.LastName, Status = true }; OnCustomerUpdated(this, args); }

protected void OnCustomerUpdated(object sender, CustomerUpdatedEventArgs e) { if (CustomerUpdated != null) { CustomerUpdated(sender, e); } } } Figure 12: Updating a Customer type from the ViewModel

Desktop with Spider this particular topic though, so I recommend doing your research to find what you feel works best for the applications you’re building when you need to call a Network with Spider portable media) ViewModel method as a UI event fires. Publish ((forfor portable media) Web with Spider includes You’ll notice that no data is passed to UpdateCustomer, so how is the proper Engine for Linux 64-bit customer object updated? If you look back in Figure 6, the data-binding syntax bound the DataForm’s CurrentItem property to the CurrentCustomer property of Engine for Win & .NET the ViewModel. Anytime a different customer is displayed in the DataForm, the CurrentCustomer is automatically updated in the ViewModel. The Smart Choice for Text Retrieval® since 1991 Figure 12 shows how customer data that has been edited can be updated. Once “Bottom line: dtSearch the update operation is completed, an event is raised in the ViewModel that is manages a terabyte of text handled by the user control to show a message box (refer back to Figure 11). in a single index and returns results in less than a second” — InfoWorld More DataForm Discussions Ahead In this article, we’ve only scratched the surface of what the DataForm control dtSearch “covers all data sources … powerful Web- can do. You’ve seen how it can be used to display an object’s properties auto- based engines” — eWEEK matically and how fields can be customized to meet your specific business “Lightning fast ... performance needs. In the next article, I’ll continue discussing the DataForm and talk about was unmatched by any how interfaces such as IEditableObject can be used as well as how custom attri- other product” butes can be applied to properties to handle data validation. — Redmond Magazine See www.dtsearch.com for hundreds more reviews, and hundreds of developer case Code accompanying this article is available for download at devproconnections.com. studies

Fully-Functional Evaluations Dan Wahlin, a Microsoft MVP for ASP.NET and XML web services, founded the XML for ASP.NET Developers website and The Wahlin Group (www.TheWahlinGroup.com), which 1-800-IT-FINDS specializes in .NET, Silverlight, and SharePoint consulting and training solutions. www.dtsearch.com

40 November 2009 | www.DevProConnections.com

Feature LANGUAGES: C# By Dino Esposito

Web Development in the Next Decade Discover features and tools in Visual Studio 2010

or web developers, the release of Visual Studio 2010 trols, scripts, images); configuring the host environment celebrates 10 years of ASP.NET development—and 10 (creating virtual folders, mapping resource types, managing F rich and profitable years, indeed. Since the first alpha credentials); and installing databases. How you accomplish shipped in the summer of 2000 (and still named ASP+), these steps depends on whether you are in an ISP or an ASP.NET has come a long way, duplicating itself in two enterprise scenario. In any case, deploying web applications frameworks: classic ASP.NET Web Forms and ASP.NET MVC. commonly turns out to be a sequence of manual operations that takes hours to complete effectively. Gone are the days in which writing a web application meant assembling a bunch of dynamic HTML pages. It’s not surprising then that several companies invested in the Whether you author your pages within a graphical designer creation of ad hoc tools to make web deployment a smoother or by tapping into a text editor, the help of an integrated process. Visual Studio 2010 is the first version of Microsoft’s development environment (IDE) is absolutely essential. flagship developer product to ship with an integrated solu- Visual Studio 2010 is the newest development environment tion for deployment. Up until Visual Studio 2008, you had that offers web developers full IntelliSense support for automatic tools to copy websites and package content into a jQuery and JavaScript, HTML snippets, smooth Silverlight precompiled folder. Zipping the content was a task left to you, integration, and one-click deployment. and it involved taking a snapshot of IIS and registry settings, databases, security certificates, and scripts for copying certain Visual Studio 2010 is a significant milestone for web devel- components into the Global Assembly Cache (GAC). opers because it’s the first version of Visual Studio that natively supports the two paradigms of ASP.NET devel- Visual Studio 2010 comes with a new tool that is also available opment: ASP.NET Web Forms 4 and ASP.NET MVC 2.0. as a separate download—the Microsoft Web Deployment Tool Here’s a preview of enhancements and new features.

Tools for Web Deployment With every new version of Visual Studio, Microsoft delivers a significantly improved set of tools to smooth the other- wise hard and somewhat repetitive work of programming. Tools definitely make many aspects of development more sustainable and make it affordable to write more and more powerful applications in the same amount of time, or faster. In Visual Studio 2010, deployment is the area where most of the enhancements are concentrated. So let’s start there.

Deploying web applications has never been an easy task. A typical web application has a number of dependencies on databases, web server configuration, and registry set- tings. To install a web application, you need to go through Figure 1: Setting up a web package three macro steps: copying the web content (pages, con-

42 November 2009 | www.DevProConnections.com named web.XXX.config where XXX stands for the configu- ration name—for example, web.release.config.

You edit web.release.config to contain only the sections in the original web.config you need to update when the appli- cation is built for release. The following content in web .release.config replaces the actual content of the matching section of the development web.config file. The transforma- tion will only occur if you build for release.

Figure 2: Importing a web package into IIS 7 The XDT transform syntax is not limited to replacements. (msdeploy.exe). It’s a command-line tool that you can use to It supports several options, including removal or insertion package the entire web content of an application to a .zip file, of attributes. For example, the script above also removes including any dependencies it may have on IIS settings, certifi- the debug attribute when compiling for release. The trans- cates, and GAC components. In Visual Studio 2010, you set up formed web.config goes into the web package when this is a web package by selecting the Package/Publish tab from the generated. You actually create a web package by right- project’s properties in Solution Explorer (Figure 1). clicking the project name and selecting Package|Create Package. Visual Studio 2010 can also automatically script the data and schema of any SQL Server databases your application MSDeploy and web.config XDT transformations help you depends upon and package it for deployment along with any only in the packaging phase of the application deployment. web content. A web package comes in the form of a .zip file You still need to log in to the target IIS (often remotely) and that can be imported into any host IIS server and run using import the package. With the One-Click Publish feature, you the IIS UI Wizard or a PowerShell script (Figure 2). can publish content and settings right from the develop- ment machine to the production environment, in just one A good share of changes that need to be made during click from an ad hoc toolbar. Through Visual Studio 2010, deployment time affect settings in the application’s web.con- you create a publish profile for the server of choice and save fig file. Things like connection strings, for example, must be your credentials securely. Next, by clicking a button in the adapted to machine, database names, and security settings toolbar, the credentials stored in the saved profile are used of the target host. The new XML Document Transform (XDT) to connect, and associated content is uploaded and imported engine in Visual Studio 2010 offers an easy solution to auto- automatically. In addition, with Visual Studio 2010 you can matically adapt the current, trigger the publish operation using an MSBuild command. To development-time content build a publish profile, you of web.config to the content right-click the project name, required in the production select Publish, and the dia- environment. You add a log box in Figure 4 appears. web.config transform by right-clicking on web.config Source View in Solution Explorer, as in Enhancements Figure 3. That covers enhancements in the deployment area. A child web.config file is Now let’s look at new facili- created for each registered ties for code writers. This configuration, including area was largely improved custom configurations you in earlier versions of Visual may have created from the Studio, so there are not as Figure 3: Adding transforms Configuration Manager. many new features to dis- Figure 4: Creating a Publish to web.config profile A child web.config file is cuss for Visual Studio 2010.

DevConnections | November 2009 43 Feature Web Development in the Next Decade

Forms, Dynamic Data controls, and ASP.NET AJAX. It’s all about small-scale changes aimed at offering developers much more control on some features of the existing framework. Examples include more control on the viewstate and on the algorithm used to generate control IDs, and the provider model has been extended to uncovered areas such as page output caching.

In the beginning, viewstate was designed to be a sustain- ing column of ASP.NET. In the long run, it ended up being perceived as one of the weakest points of ASP.NET Web Forms. Prior to ASP.NET Web Forms 4, disabling the viewstate selectively only for certain controls has not been an easy task. In the new version, a new property is added Figure 5: Inserting an HTML code snippet in the Source View of to all controls—ViewStateMode. This property takes val- an ASPX page ues from an enumeration that lists values such as Inherit, Disabled, and Enabled. The default value of Inherit doesn’t Some enhancements appear in the support for CSS 2.1 in change the behavior you get in ASP.NET 3.5. If you set it to design view and in the tools for ensuring an even stricter Disabled, though, you can disable viewstate management compliance with . As far as text editors are for a specific control regardless of the viewstate settings for concerned, code snippets in the source view of web pages is a its parent. This is a quantum leap from previous versions— long-awaited feature that is now available. HTML snippets are you can now easily serialize to the viewstate only the con- an extremely handy feature aimed specifically at developers trols that really need to. who spend a lot of time in the text editor rather than in the graphical designer. Figure 5 shows HTML snippets in action. Another noticeable change addresses a new issue raised with AJAX client-side development. In ASP.NET, data- You manage such snippets in much the same way you did bound and template-based controls repeat HTML blocks for for other types of snippets in previous versions of Visual each data item. HTML literals are emitted as is; server con- Studio. HTML snippets are managed via the Code Snippet trols are processed to HTML. In doing so, emitted HTML Manager (from the Tools menu) and are actually XML files tags are given a unique ID. The ID, though, may be hard saved in the following folder: to guess, and this hinders the creation of script blocks for client-side action. In ASP.NET 4, the new ClientIDMode C:\Program Files\Microsoft Visual Studio 10.0\Web\Snippets\HTML\1033\ HTML property defined on controls allows you to decide how the ID for internally generated elements should be generated. IntelliSense for JavaScript is not a new feature because You can choose to proceed as in previous versions (default it appeared in Visual Studio 2008. In Visual Studio 2010, option), use the same algorithm as the parent control, or the IntelliSense engine has been improved for accuracy use a static ID that will not be scoped to any container and optimized for performance. Overall, it is now more and might generate duplicates. Finally, you can choose to responsive, provides more auto-completion tips, and tracks generate predictable IDs that result from the concatenation namespaces. of parent IDs, skipping over content page placeholders and naming containers. Finally, the jQuery library is now officially part of the Visual Studio 2010 package with full and detailed Intel- Introduced with ASP.NET 2, the provider model decouples liSense support. (All of this is nothing new, but it required certain areas of functionality from the actual implementa- a separate download in earlier versions.) tion. Until version 4, no provider model was set for page output caching. In the new version, you can define disk- ASP.NET Web Forms 4.0 based output caching providers, mostly to reduce the pres- Visual Studio 2010 is the IDE that goes hand in hand with sure on the web server that originates from keeping too .NET Framework 4. For web developers, this means hav- many pages in memory. Extending the provider model to ing available a slightly richer and improved ASP.NET Web the area of caching also lays the groundwork for integrat- Forms framework and the brand-new ASP.NET MVC 2 ing more powerful caching engines into ASP.NET. Microsoft framework. Let’s see what’s new in both. “Velocity” is just round the corner.

ASP.NET Web Forms 4 has the same foundation as ASP.NET The wave of changes in ASP.NET Web Forms doesn’t end 3.5 SP1 and provides further refinement in the area of Web here and also touches on the AJAX area. In first place, the

44 November 2009 | www.DevProConnections.com Microsoft client script library has been refactored into smaller helpers for generating basic chunks of HTML (TextBox, pieces, so you can link exactly the functionalities you need. action link, form), in ASP.NET MVC 2 you also have more Likewise, the ScriptManager has been updated to work with abstract helpers such as Html.EditorFor. This helper method the new granularity of script files. Finally, client-side data is smart enough to output the appropriate HTML element based on the type to be edited. For example, driven rendering, and support for ADO.NET Data Services the helper will generate an input field for a string property characterize the new AJAX platform in ASP.NET 4. and a check box for a Boolean. The EditorFor method, how- ever, also supports templates for developers to completely As you can see, no big changes will occur in Web Forms customize the output. Templates are expressed as ASCX (except the AJAX support), but as a developer you certainly user controls saved to a particular folder under Views and gain much more control over certain key features. named according to the intended role and target type.

ASP.NET MVC 2.0 A Clean and Tidy Version ASP.NET MVC 2 extends current version 1.0 without revo- Visual Studio 2010 is here, and it gives ASP.NET developers lutionizing it. Version 2 essentially adds a few new features, a clean and tidy version to work with because it incorpo- three of which are worthy of mention here. The first new rates many of the technologies and frameworks that Micro- feature is the concept of the area. An area allows you to soft released in sparse order in the past couple of years. more easily partition functionalities across an MVC appli- This includes web deployment technologies and, of course, cation. An area consists of a significant section of a large ASP.NET MVC. In this regard, I personally consider Visual MVC application that you develop and manage separately Studio 2010 one of the most significant major releases of as a distinct project. Areas are then referenced by the main the IDE. application. Typically, you create an ASP.NET MVC area for each functional area you recognize in the application; an Today ASP.NET development means choosing between two area is a sort of sub-application within the main root appli- frameworks pushing radically different paradigms. If you cation. are a Web Forms developer, you won’t find big changes in this release. On the other hand, ASP.NET Web Forms is a ASP.NET MVC 2 now includes built-in support for data stable and mature platform with not much room left for annotations—an effective way to create an attribute-based changes—unless you’re looking for really radical changes. validation layer in classes being used as the view-model, But if you’re just looking for radical changes in the devel- if not the model entirely. Data annotations are attributes opment model, what about ASP.NET MVC? Visual Studio already part of the .NET Framework 3.5 SP1, but now ASP 2010 comes with version 2, which is essentially version 1.0 .NET MVC 2 provides automatic binding and UI helper plus areas and templated helpers. And Silverlight 3 is also validation support for it. Here’s an example of data annota- natively supported and fully integrated with the product. tions: Can you ask for more? All in all, fun never ends for web developers in Microsoft land. Enjoy! using System.ComponentModel.DataAnnotations; public class Person { [Required(ErrorMessage="Required field"] public string FirstName {get; set;}

[Required(ErrorMessage="Required field"] [StringLength(50)] public string LastName {get; set;}

[Range(1, 100)] public int Age {get; set;} : }

The state of an annotated object can be checked via a method, and the new ASP.NET MVC project knows how to scaffold an annotated object to a view that automatically contains UI elements for validating input. Overall, it is not really different from what you get out of the DataForm con- Dino Esposito, an architect at IDesign, specializes mainly in ASP trol in Silverlight 3. .NET, AJAX, and RIA solutions. Dino co-authored the best-seller Microsoft .NET: Architecting Applications for the Enterprise (Micro- Finally, the rather basic technology behind HTML helpers soft Press) and the just-released twin book Microsoft ASP.NET and gets smarter as it begins to support templates. Along with AJAX: Architecting Web Applications ().

DevConnections | November 2009 45 Get SQL Server Magazine @ Off 58% the Cover price! Only $29.95*—it’s like getting every other month FREE! 5 More Reasons You Won’t Want to Miss a Single Issue:

● ACCESS TO EXPERTS: Solve your toughest IT headaches with in-depth columns by Kalen Delany, Itzik Ben-Gan, and Brian Moran. ● UP-TO-THE-MINUTE: Comprehensive coverage of T-SQL, Reporting Services, log fi les, business intelligence, SharePoint, and much more. ● COMMUNITY-WIDE RESOURCES: Access to blogs, forums, Web updates, events and news alerts on the absolute latest industry developments as they happen. ● EXCLUSIVE ACCESS: Subscriber-only access to the entire We’ll also send you the latest SQL Server Magazine online article database. SQL Server 2008 System Table ● RISK-FREE OFFER: If you’re not satisfi ed with SQL Server Map Poster FREE with your Magazine at any time, simply cancel your subscription and receive a paid order! refund for any un-mailed issues.

Start Your Subscription Now at

*Rates vary outside the U.S. SQLMag.com/go/asp Need Feature phphotooto LANGUAGES: C# ASP.NET VERSIONS: 3.5 By JuliaJulia LeLermanrman

Renovations to .NET 4.0’s Entity Framework Entity Framework 4 offers a more intelligent, accessible framework

he ADO.NET Entity Framework (EF) was released last summer as part of Visual Studio (VS) 2008 SP1. This Twas the first round of Microsoft’s long-term vision for the Entity Framework. VS 2010 brings us the next evolution of the Entity Framework and includes many major enhance- ments that are a result of valuable feedback from the community.

While there are myriad improvements throughout the Entity Framework, this article will focus on 11 of the most signifi- cant new features and changes in this version. Although this is the second iteration of EF, it is being referred to as Entity Framework 4 (EF4), to align with .NET 4.0, the new version of the .NET Framework. Two of the features cov- ered in this article will be included in a separate installation referred to as the Entity Framework Feature Community Technology Preview (CTP). Eventually these will be rolled Figure 1: SalesOrderHeader entity with plural names into Visual Studio and .NET, but not for the VS 2010 release automatically applied to manufacturing (RTM). This article was written using VS 2010 Beta 1. I’ve noted known changes for Beta 2 and RTM. SalesOrderHeader entity. The wizard automatically applied the correct singular and plural forms to this entity. The 1. Better Entity Naming by the EDM Wizard navigation properties now relate to the multiplicity of their One of the biggest problems with the VS 2008 Entity Data related entities (e.g., Address points to a single Address Model (EDM) designer is that the wizard does not auto- while SalesOrderDetails points to a collection of detail matically apply singular and plural names to entities when entities). they’re being generated from the database. An entity is a single item, therefore it is logical for its name to be singu- Not only does the wizard determine whether singular or lar. An EntitySet is a wrapper for a set of entities, therefore plural is correct, but it also is capable of properly fixing up its name should be plural. However, the wizard merely every English table name I’ve tried so far. For example, it duplicates the name of the tables from which the model is correctly gives me People as the plural of Person and Brew- derived. As a result, developers spend a lot of time manu- eries as the plural for Brewery. If the table name starts out ally renaming entities, their EntitySets, and navigation as a plural name, the wizard ensures that the entity name properties in new models. This has been very frustrating, is singular. especially when there are a large number of entities in the model. 2. Model-First Design Entity Framework version 1 (EF1) targets developers who The EF4 wizard can now apply the appropriate names want to build a model from an existing database. EF4 now throughout the model. Figure 1 shows an example of a allows developers to use the EDM Designer to create a

DevConnections | November 2009 47 Feature Entity Framework 4

Figure 4: Entity that contains the complex type Name Figure 2: Refactoring a set of properties into a complex type that define a Customer’s name, then chose to refactor them model, then generate database schema from that model. into a complex type. The Designer has a new context menu option, Generate Database Script from Model. This feature will build a data- The results of this refactoring are shown in Figure 3. The base script that you can then run in your database. The entity contains the complex type property which, unfortu- script doesn’t create the actual database file but all the nately, cannot be expanded. But you can see the different tables, keys, and constraints based on the model. You’ll properties of Name in the mappings and how they map need to be explicit in the model about defining the attri- back to the table columns. butes of properties. The updated designer provides more control over attributes such as StoreGeneratedPattern (e.g., As with EF1, the complex types are available in code when auto-incremented values), foreign key constraints, and cas- querying and working with the entity objects. cade deletes. Be aware that running the script against an IEnumerable contactsQuery = from c in context.Customers existing database will overwrite any existing data. orderby c.Name.LastName select c; Model-first design in EF4 depends on a combination of a T4 template and a workflow, which makes the generation The object contains the complex type, as shown in the completely customizable. Look for more information com- debug window in Figure 4. ing from the Entity Framework team on how to customize the generation of your database scripts. 4. New Way of Generating Classes from the Model 3. Complex Type Support in the Designer EF has traded in the proprietary code-generation API that Complex types are an essential element in the EDM. They was part of EF1 for Visual Studio’s T4 Code Generator. T4 let you encapsulate a set of fields into a property. Unfortu- (Text Template Transformation Toolkit) is a powerful tool nately, the EF1 designer does not support complex types, that was introduced in VS 2008. With T4, you create code which makes it very difficult to work with them. The new generation instructions by combining T4 syntax with C# or designer allows you to define and reuse complex types in Visual Basic, then link this file to some metadata, such as your model. In Figure 2, I’ve selected Customer properties an .edmx file. T4 will automatically process the template against the metadata and create a new code file based on the output.

EF4 contains a default template that’s used to generate classes from the EDM. But you can override this default. The EDM Designer has a context menu option, Add New Artifact Genera- tion Item, which lets you take control of the tem- plate so that you can customize it. (Note that the menu option name might change by RTM.) EF Figure 3: Complex type properties seen in mappings copies the template into your project (see the .tt

48 November 2009 | www.DevProConnections.com public class AWContext : ObjectContext { private ObjectSet _lineitems; public AWContext() : base("name=AWLTEntities", "AWLTEntities") { _lineitems = CreateObjectSet(); } public ObjectSet LineItems { get { return _lineitems; } } } Figure 5: Custom T4 template, Model1.tt Figure 7: Wrapping the LineItem class as a queryable ObjectSet file in Figure 5); then all subsequent code generation from This will not only allow you to use LINQ to Entities to your model will come from this template. By customizing construct queries, but it will enable your classes to partici- the template, you can take ownership of the definition of pate in EF’s change tracking. Figure 7 creates the context the classes that are built based on the model. class, ties it to the model, and wraps the LineItem class as a queryable ObjectSet. 5. Support for POCO Objects EF1 allows you to use your own classes and still benefit There is much more that you can do once you’ve set up the from the model, querying, and change tracking. However, proper pattern for using your own classes in EF4. Check the your classes still require some tight binding to the EF APIs, ADO.NET (Entity Framework) Team Blog at blogs.msdn either by inheriting from EntityObject or implementing .com/adonet for a series of posts on POCO with EF4 writ- some of EF’s interfaces. EF4 removes that constraint. You ten in June 2009. can now use objects that have no knowledge of the Entity Framework. There are two steps to enabling this Plain Old 6. Code-Only Support : CLR Object (POCO) support. The first step is to ensure POCO Classes with No Model that your class, property names, and types line up with the The Entity Framework Feature Pack, which will be released entity, property names, and types defined in the EDM, as separately from VS 2010, contains support for "code-only" Figure 6 shows. Using the Convention over Configuration development. This is the most agile way of using Entity pattern, EF will assume that the names line up and use that Framework. With code-only, you will not even need to cre- assumption to work out the relationship between the class ate an EDM. EF does rely on the metadata supplied by the and the model. model, but the code-only mechanism will create that meta- data on the fly based on the existing classes and some addi- The second step is to create an ObjectContext class with tionally provided information. It’s a hugely powerful feature properties that return the ObjectSets of the classes. Object- for Domain Driven Development and is still evolving. Set is new to EF. In EF1, when you called an EntitySet, such as context.People, it returned an ObjectQuery of entity 7. Enhanced Support for Stored Procedures types. In EF4, the return is an ObjectSet of entity types. EF4 Beta 1 includes a number of enhancements for stored The ObjectSet is a variation on an ObjectQuery and is less procedure support, and Beta 2 promises even more. The tightly bound to the query. (ObjectSet gives you another one that I’m most happy to see is support for stored pro- thing to look forward to—easier mocking for unit tests.)

Figure 6: EF using classes, names, and properties to match existing entities Figure 8: Complex type created in the Model Browser

DevConnections | November 2009 49 Feature Entity Framework 4

8. Lazy Loading Support Developers familiar with ORMs are used to having related data loaded automatically on demand. EF1 does not sup- port implicit loading, although it does have eager loading (with the Include method) and explicit loading with the Load method.

EF4 introduces the ability to instruct an ObjectContext to implicitly load related data on demand using the new ObjectContext.ContextOptions.DeferredLoadingEnabled property. This property is false by default. Once you’ve set the property to true, EF will implicitly load related data.

By setting DeferredLoadingEnhabled to true, EF will query the database to get the related orders for each Customer. Figure 9: Mapping a stored procedure to a complex type Otherwise, the counts will always return 0. Be aware that if there are 200 customers, lazy loading will mean 200 addi- cedures that return results that don’t match an entity. EF1 tional database calls. only allows you to map READ stored procs that line up context.ContextOptions.DeferredLoadingEnabled=true; with an entity or return a scalar value. Now you can create IEnumerable custs = context.Customers; a complex type and use that as the target of a function that foreach (Customer c in custs) { imports a stored procedure into your model. Console.WriteLine(c.SalesOrderHeaders.Count); } My database has a stored procedure that returns a name and ID. I can create a complex type in the Model Browser In Beta2, note that DeferredLoadingEnabled will be changed that matches these results, as Figure 8 shows. to LazyLoadingEnabled. More importantly, for newly created models, lazy loading wil be enabled by default. Now I can map the stored procedure to the CustName com- plex type, as shown in Figure 9. The default code generator 9. Foreign Key Support—Coming in Beta 2 creates a function of the ObjectContext that lets me easily The EDM in EF1 stays true to its inspiration, the Entity call this function and materialize objects from the results. Relationship Model, which buries foreign keys in the map- pings. Foreign keys are nowhere to be found in the concep- List custs = context.GetNames().ToList(); tual model, which became a big source of frustration for many developers. EF4 now supports the ability to create a Stored procedures that return scalar values also benefit model with relationships defined with foreign keys as scalar from the code generator’s new ability to call the functions values. In fact, this will be the default when you create a from the ObjectContext. Here’s a call to the YearswithSales- model with the EDM wizard. Querying the model won’t GreaterThan function that’s mapped to a stored procedure change dramatically; however, the exposed foreign keys will that returns strings. make interacting with related objects much easier in many scenarios. Although the EF team has written about foreign IEnumerable salesYears = context. YearswithSalesGreaterThan(5000); key support on blogs.msdn.com/efdesign, the feature will not be available until Beta 2.

One other notable improvement to stored procedures in 10. Self-Tracking Entities EF4 Beta 1 is in function mapping. When mapping Insert, Self-Tracking Entities is an important part of the Feature Update, and Delete stored procedures to entities via func- CTP that will relieve the pain many developers have tion mapping, EF1 required that you map all three. With felt when using the EF in services and websites. EF’s EF4, you can map only one or two of the functions. Then SaveChanges method relies on change-tracking information when you call SaveChanges, the mapped functions will be (original values and EntityState) to push modifications to used where available and Entity Framework will generate the database. But in EF1, the entities know only about their commands for modifications that don’t have associated current values. It is the ObjectContext that keeps track of functions. the state information. However, because the context is not serializable, moving that state information across processes Look for even more support for stored procedures in the is a complicated challenge. In EF4, you have the option of Beta 2 and RTM versions of VS 2010. encapsulating the change information within the entities

50 November 2009 | www.DevProConnections.com so that information can be carried around with the entities. It’s easy to call in Entity SQL. This makes updates across processes almost effortless. SELECT c.contactId, FullName(c) FROM MyEntities.Contacts as c To create self-tracking entities, you’ll use a T4 template provided in the Feature CTP. The resulting classes are POCO For LINQ to Entities, you’ll have to create a related method classes with no dependency on the Entity Framework. This in your entity class, and then you can use the function in way, client applications that consume these classes will not your query. need to have a dependency on EF. from p in context.People orderby Functions.FullName(p) Essentially, the new entities keep track of their state—such select new {p.PersonID, FullName=Functions.FullName(p)} as Modified or Added. When they come across a process, you can attach them to an ObjectContext without losing It’s also possible to create model-defined functions to return that key piece of change-tracking information. Attaching a entities, collections, and other types. self-tracking entity to a context will automatically render its state as Unchanged, just like any other entity. However, the A More Efficient, Accessible Framework CTP has a new extension method for ObjectContext called In this article, I’ve touched on 11 of the enhancements to ApplyChanges that will pull in the entity and, at the same EF that you’ll find in VS 2010 and .NET 4.0. Although time, fix up its state. these are the most significant improvements to EF4, there are so many other changes, great and small, throughout using (var context = new MyEntitiesContainer()) { the designer and the APIs, making EF4 a technology context.Entries.ApplyChanges(customerWithOrders, that will be much more palatable to a wider audience EntityChangeTrackerAdapter.GetSelfTrackingEntityInfo); context.SaveChanges(); of developers. }

What’s especially nice is that if the entity you pass in is a graph, it will do the same to all the entities in the graph. There is no comparable function to this when working with regular entity objects and graphs.

11. Model-Defined Functions EF lets you add custom properties to the model classes that aren’t defined in the model. For example, if your database table and entity both contain a FirstName and LastName column, you can create a class-level property, FullName, that concatenates these two fields. The drawback of this is that because the new custom property is not part of the model, you can’t use it in either LINQ to Entities or Entity SQL queries. Additionally, if you’re sharing your model with another application, you need to share the classes that con- tain the custom properties as well.

EF4 provides a solution to this: model-defined functions. We now have the ability to define functions directly in the conceptual model. Currently there is no designer support for this, so you would have to input the XML directly.

Here is a model-defined function for the FullName func- tion. It takes a Contact type as a parameter and performs the operation defined in the DefiningExpression tag on that type. Julia Lerman ([email protected]) is a Microsoft MVP, .NET mentor, and consultant. Julie presents on data access and other topics at user groups and conferences around the world, blogs Trim(c.LastName) + ", " + c.FirstName at thedatafarm.com/blog, and is the author of Programming Entity Framework (O’Reilly). Follow Julie on Twitter at julielermanvt.

DevConnections | November 2009 51 Feature By Stephen Walther

What’s Coming in Microsoft AJAX? The Microsoft AJAX Library will unify the AJAX Control Toolkit, jQuery, and ASP.NET AJAX into a single library

he Microsoft AJAX Library is undergoing a dramatic that you can use just like any of the other web form controls. transition. We're unifying our AJAX toolkits and Tlibraries into a single Microsoft AJAX Library. The The jQuery Library goal is to create a single Microsoft AJAX Library that you ASP.NET MVC developers want to retain fine-grained control can use when building ASP.NET Web Forms, ASP.NET over their markup and JavaScript. For this reason, ASP.NET MVC, and even pure AJAX applications. In this article, MVC developers gravitate toward jQuery when they want to I’ll provide an overview and roadmap of the changes that add AJAX functionality to a web application. If you want to get you’ll see in Microsoft AJAX over the coming months. your hands dirty with JavaScript, then jQuery is a natural fit.

ASP.NET AJAX, AJAX Control Toolkit, To make it easy to use jQuery, Microsoft ships jQuery as a and jQuery standard part of the ASP.NET MVC framework. When you Historically, Microsoft has promoted several approaches create a new ASP.NET MVC project, jQuery is included in to building AJAX applications: the AJAX Control Toolkit, the Scripts folder in the new project automatically. jQuery, and ASP.NET AJAX. The different approaches appeal to different developer audiences. ASP.NET AJAX During the past year, Microsoft released several preview The AJAX Control Toolkit versions of a new AJAX library named ASP.NET AJAX. ASP The AJAX Control Toolkit is one of the most popular Code- .NET AJAX is a JavaScript library that works with all mod- Plex projects of all time. Millions of developers have down- ern browsers. You can use this new AJAX library in both loaded the AJAX Control Toolkit (the project averages more ASP.NET Web Forms and ASP.NET MVC applications. than 25,000 downloads a week). ASP.NET AJAX has generated a lot of excitement among The AJAX Control Toolkit contains a collection of more than ASP.NET developers at conferences such as MIX and Tech- 30 server-side controls that make adding JavaScript function- Ed. ASP.NET AJAX talks have consistently been among the ality to an ASP.NET Web Forms application easy. For exam- highest audience-rated presentations at these conferences. ple, you can use the AJAX Control Toolkit to display modal pop-up dialogs, auto-complete textboxes, color pickers, and The focus of ASP.NET AJAX is on pure client-side develop- HTML editors. ment. ASP.NET AJAX enables you to build database-driven web applications that execute entirely in the browser. For ASP.NET Web Forms developers are the main audience for example, by taking advantage of ASP.NET AJAX client tem- the AJAX Control Toolkit. Although, theoretically, it has been plates and controls, you can retrieve database data from a possible to use the AJAX Control Toolkit in an ASP.NET MVC web service and format the data using a client template. application, it isn't a recommended or enjoyable experience. ASP.NET AJAX supports both retrieving and updating data- base data from the browser. One of the attractive features of the AJAX Control Toolkit for Web Forms developers is that you don't need to know The Microsoft AJAX Library JavaScript to take advantage of the toolkit. All the messy cli- The fact that Microsoft has multiple toolkits and libraries is ent-side details are encapsulated in server-side web controls confusing to developers. It also means that resources that

52 November 2009 | www.DevProConnections.com we invest in one area don’t benefit other areas. For exam- Notice how this code uses a jQuery selector in combina- ple, creating a new AJAX Control Toolkit control benefits tion with the imperative control creation syntax of the new ASP.NET Web Forms developers, but a new control does Microsoft AJAX Library. The Microsoft AJAX Library is not benefit ASP.NET MVC developers. designed to enable developers to seamlessly move back and forth between jQuery code and Microsoft AJAX code. Our goal is to create one unified AJAX library—named the Microsoft AJAX Library—that unifies the AJAX Control Tool- Finally, the new Microsoft AJAX Library is built on top of kit, jQuery, and ASP.NET AJAX into a single library. That ASP.NET AJAX. That means, in the Microsoft AJAX Library, way, you can use one AJAX library regardless of whether you can take advantage of all the new innovations devel- you’re an ASP.NET Web Forms or ASP.NET MVC developer. oped for ASP.NET AJAX, such as client controls, client tem- We want to improve the experience of building AJAX appli- plates, and client data access. cations for all ASP.NET developers. The Microsoft AJAX Library combines the best features of the AJAX Control Tool- kit, jQuery, and ASP.NET AJAX into one library. The Microsoft AJAX Content Delivery Network The new Microsoft AJAX Library includes almost all the We want to make it easy for developers to use the Microsoft controls from the AJAX Control Toolkit. However, unlike AJAX Library. For this reason, we recently launched a Con- the AJAX Control Toolkit controls, you can use the controls tent Delivery Network (CDN) that enables you to use the in the Microsoft AJAX Library in both ASP.NET Web Forms Microsoft AJAX Library (including jQuery) without install- and ASP.NET MVC applications. ing the library on your server.

You can use a Microsoft AJAX Library control in a Web By taking advantage of the Microsoft AJAX CDN, you can Forms application in exactly the same way as you use an start using the Microsoft AJAX Library by adding the fol- AJAX Control Toolkit control right now. You can drag the lowing

You also can use a Microsoft AJAX Library control in an If you’re an ASP.NET MVC developer, this is the recom- ASP.NET MVC application by instantiating the control in mended way of using the Microsoft AJAX Library in your JavaScript code. For example, you can create a Watermark MVC applications. There is no reason to install the JavaScript control in an ASP.NET MVC application by using the new files from the Microsoft AJAX Library on your web server. Microsoft AJAX Library control creation syntax like this: Using the CDN improves the performance of your web appli- cation because the CDN caches the Microsoft AJAX Library Sys.attach.Watermark("firstname", "Enter your first name"); across the world and across website domains.

The new Microsoft AJAX Library also leverages the unique If you're an ASP.NET Web Forms developer, we recommend features of the jQuery library. The jQuery library has a that you install the Microsoft AJAX Library by visiting the powerful selec- ASP.NET AJAX website at www.asp.net/ajax. When you tor syntax that install the Microsoft AJAX Library, a set of server-side makes it easy Microsoft AJAX Library controls is installed in the Visual to retrieve DOM Studio toolbox. elements using a syntax familiar We also make it easy for ASP.NET Web Forms developers to from Cascading take advantage of the Microsoft AJAX CDN. The ASP Style Sheets. For .NET 4.0 server-side ScriptManager control includes a new example, you can EnableCdn property. When you assign the value true to this use the following property, the ASP.NET 4.0 framework uses the CDN auto- JavaScript code matically. By setting this one property, you get all the perfor- to attach a Water- mance benefits of the CDN in a Web Forms application. mark control to every input ele- You can learn more about the Microsoft AJAX CDN by visit- ment in a page: ing the ASP.NET AJAX website at www.asp.net/ajax.

Figure 1: Dragging Microsoft AJAX controls $("input").attach The Client Script Loader from the toolbox .Watermark("watermark text"); Much of the magic of the new Microsoft AJAX Library

DevConnections | November 2009 53 Feature What's Coming in Microsoft AJAX?

detail form (Figure 4). The master form displays

Movies

a list of movie titles and the details form displays
  • {{title}}
  • details for the selected movie. You would use the
code in Figure 5 to create the master/details form Figure 2: Creating a client DataView control Providing Full Microsoft Product Support comes from the One barrier that companies encountered in the past when new client Script they wanted to use the AJAX Control Toolkit is that the Loader. For AJAX Control Toolkit is not a formally supported Microsoft example, the cli- product. The AJAX Control Toolkit receives informal sup- ent Script Loader port through CodePlex and the ASP.NET forums. is what makes it possible to eas- One of our long-term goals with the new Microsoft AJAX ily create AJAX Library is to provide formal Microsoft product support for Control Toolkit the AJAX Control Toolkit controls. We want to include controls in an almost all the existing AJAX Control Toolkit controls in the ASP.NET MVC new Microsoft AJAX Library. However, we're not ready to application. provide full Microsoft product support for all the existing AJAX Control Toolkit controls. The client Script Loader loads Therefore, we’ve divided the Microsoft AJAX Library into Figure 3: Using ASP.NET AJAX all the scripts a core and an extended library. The core Microsoft AJAX required by a cli- Library contains a subset of the AJAX Control Toolkit con- ent control (or client type) in the right order automatically. trols. Microsoft Support Services will fully support these For example, you can create a client DataView control that controls. This means that, if you encounter an issue with displays a list of movies by using the code in Figure 2. Each the core library, you can call Microsoft support services, movie in the array of movies is formatted with the template say, at 3:00 A.M. on a holiday and open a support ticket. contained in the movieList UL element, as Figure 3 shows. However, the Microsoft AJAX Library also includes an extended library. The extended library contains the AJAX When you create a client DataView control, the client Script Control Toolkit controls for which we're not prepared to Loader loads all the JavaScript files required by the Data- provide formal Microsoft support. Over time, we plan to View behind the scenes. Notice that the code in Figure 2 migrate these controls one by one from the extended library contains a single Figure 2: Creating a client DataView control Providing Full Microsoft Product Support comes from the One barrier that companies encountered in the past when new client Script they wanted to use the AJAX Control Toolkit is that the Loader. For AJAX Control Toolkit is not a formally supported Microsoft example, the cli- product. The AJAX Control Toolkit receives informal sup- ent Script Loader port through CodePlex and the ASP.NET forums. is what makes it possible to eas- One of our long-term goals with the new Microsoft AJAX ily create AJAX Library is to provide formal Microsoft product support for Control Toolkit the AJAX Control Toolkit controls. We want to include controls in an almost all the existing AJAX Control Toolkit controls in the ASP.NET MVC new Microsoft AJAX Library. However, we're not ready to application. provide full Microsoft product support for all the existing AJAX Control Toolkit controls. The client Script Loader loads Therefore, we’ve divided the Microsoft AJAX Library into Figure 3: Using ASP.NET AJAX all the scripts a core and an extended library. The core Microsoft AJAX required by a cli- Library contains a subset of the AJAX Control Toolkit con- ent control (or client type) in the right order automatically. trols. Microsoft Support Services will fully support these For example, you can create a client DataView control that controls. This means that, if you encounter an issue with displays a list of movies by using the code in Figure 2. Each the core library, you can call Microsoft support services, movie in the array of movies is formatted with the template say, at 3:00 A.M. on a holiday and open a support ticket. contained in the movieList UL element, as Figure 3 shows. However, the Microsoft AJAX Library also includes an extended library. The extended library contains the AJAX When you create a client DataView control, the client Script Control Toolkit controls for which we're not prepared to Loader loads all the JavaScript files required by the Data- provide formal Microsoft support. Over time, we plan to View behind the scenes. Notice that the code in Figure 2 migrate these controls one by one from the extended library contains a single Figure 2: Creating a client DataView control Providing Full Microsoft Product Support comes from the One barrier that companies encountered in the past when new client Script they wanted to use the AJAX Control Toolkit is that the Loader. For AJAX Control Toolkit is not a formally supported Microsoft example, the cli- product. The AJAX Control Toolkit receives informal sup- ent Script Loader port through CodePlex and the ASP.NET forums. is what makes it possible to eas- One of our long-term goals with the new Microsoft AJAX ily create AJAX Library is to provide formal Microsoft product support for Control Toolkit the AJAX Control Toolkit controls. We want to include controls in an almost all the existing AJAX Control Toolkit controls in the ASP.NET MVC new Microsoft AJAX Library. However, we're not ready to application. provide full Microsoft product support for all the existing AJAX Control Toolkit controls. The client Script Loader loads Therefore, we’ve divided the Microsoft AJAX Library into Figure 3: Using ASP.NET AJAX all the scripts a core and an extended library. The core Microsoft AJAX required by a cli- Library contains a subset of the AJAX Control Toolkit con- ent control (or client type) in the right order automatically. trols. Microsoft Support Services will fully support these For example, you can create a client DataView control that controls. This means that, if you encounter an issue with displays a list of movies by using the code in Figure 2. Each the core library, you can call Microsoft support services, movie in the array of movies is formatted with the template say, at 3:00 A.M. on a holiday and open a support ticket. contained in the movieList UL element, as Figure 3 shows. However, the Microsoft AJAX Library also includes an extended library. The extended library contains the AJAX When you create a client DataView control, the client Script Control Toolkit controls for which we're not prepared to Loader loads all the JavaScript files required by the Data- provide formal Microsoft support. Over time, we plan to View behind the scenes. Notice that the code in Figure 2 migrate these controls one by one from the extended library contains a single experimental features. Some of these features
    might make it to the core library, but some of the
  • {{Title}}
features might not.
You selected: {{Title}} – {{Director}}
The ASP.NET AJAX Wiki and sample code to this wiki. However, we also Figure 5: Creating the master/detail form using an imperative syntax hope that you'll help us grow the wiki by con- tributing content.

I’m excited about the new unified Microsoft

be happy that they now will be able to easily use
cations. And all ASP.NET developers will benefit You selected: {{Title}} – {{Director}}
from the new innovations in the Microsoft AJAX Figure 6: Creating the master/detail form using a declarative approach Library, such as client templates, client controls, and the new client Script Loader.

By the time you read this article, the Microsoft AJAX Library might have a new name. To learn more, visit www .asp.net/ajax.

Stephen Walther ([email protected]) is a senior program manager at Microsoft. He creates content around ASP.NET MVC for the www.ASP.net website. Stephen has been writing about Microsoft web technologies for a long time. His first book, Active Server Pages Unleashed, was published in 1997. He is the author of the best-selling series of books on ASP.NET, ASP.NET Unleashed.

DevConnections | November 2009 55 RequiredReading By Steve Schofield

Web Hosting Industry Trends Industry leaders share their advice on cloud computing, SaaS, and virtualization

ince the dotcom bust around 2001, the world of there is no standard definition of what cloud hosting actually Internet hosting has experienced drastic changes. is. Only time will tell how users will really make use of the STechnology comes and goes at a lightning-fast pace. cloud. I believe there will be a healthy ecosystem of hosters Web hosting trends continue to evolve. To help get a better of all types that will coexist and provide services catering to perspective, I engaged with a few people who are leaders in different workload demands of the end user.” web hosting. Their insights give a real-world perspective on the trends shaping the industry and what the industry buzz Cloud computing has also been known as “elastic comput- is all about around cloud computing, virtualization, software ing.” Coburn refers to it this way: “Elastic computing is the as a service (SaaS), and more. ability to scale your computing resources for your applica- tion as necessary. This would be the ability to increase and Cloud Computing decrease the amount of storage, memory, CPU, and general So what is cloud computing? Depending on the person computing resources available to your application.” you talk to, you’ll get a different view. Cloud computing could mean you never have to worry about your servers, or Elastic or utility computing has some early offerings in the demand on your servers, because the service is always there. industry. Storage, CPU cycles, and capacity on demand are If you need more bandwidth or server capacity, it’s automati- offerings of Amazon S3 services. Other large players, such cally available. For some, cloud computing is synonymous as and Microsoft, are targeting many offerings on with high availability or redundancy. Others would say cloud the basis of cloud computing. Google Apps offers web- computing abstracts which devices, software, or require- based functionality for word processing and spreadsheet ments are needed to connect to the cloud. I compare cloud creation. Microsoft’s Azure touts a platform for building computing with electricity. As we turn off and on devices, applications for the cloud, among other services. the power is available. We don’t worry about capacity. Regardless of what size company you're in, cloud comput- According to Brad Kingsley, of ORCSWeb.com, “[Cloud com- ing security is a big topic. Storing critical data on remote puting] is in our future and has been in our past. The shared machines that the company doesn’t control can be a calcu- web farm meets most definitions of cloud but without the lated risk. I recommend consulting with your legal depart- utility billing. We’ve done cloud since long before cloud was ment to ensure you’re considered all the eventualities. If a buzzword.” Jess Coburn of appliedi.net notes, that “what’s the cloud is offline or breached, for example, you’ll want interesting about the move towards cloud is that the defini- a clear understanding of your protections in these circum- tion of cloud is probably what’s most cloud-like among host- stances. How data is backed up and restored is another ing providers, as everyone has their own definition of what item you should consider. cloud is and cloud is not, thus confusing the consumer.” Taking a step back, the first thing you need to determine is Takeshi Eto, of DiscountASP.NET, focuses solely on advanced what problem you're trying to solve. After you know what Windows-based shared hosting. He thinks that “cloud host- you need to do, you can evaluate if cloud computing can ing is certainly an emerging and evolving segment of the help you realize your goal. Cloud computing is about mak- hosting enterprise. We will keep a close watch as to its evo- ing things more flexible, less complex, and faster to market lution. I think at this time we are seeing a lot of hype, and without being bogged down with technology. These are big

56 November 2009 | www.DevProConnections.com RS' CH RS' CH RS' CH RS' CH RS' CH E O E O E O E O E O D I D I D I D I D I A C A C A C A C A C

E E E E E

E E E E E

R R R R R

* RequiredReading Web Hosting Industry Trends goals, and, if the early successes of Amazon and Google are ers and remove them when I was finished testing. Another indicators, the future looks promising for cloud computing. favorite feature of VMware is VMotion, which moves a running VM to another host machine while a server is still Virtualization active. I recommend checking out the VMware website at Virtualization has been around since the beginning of com- www.vmware.com for more information. puters. IBM invented the concept to divide up expensive mainframe resources and maximize usage. That sounds Microsoft also provides Hyper-V virtualization, which is part similar to today’s situation—take a large physical machine, of Windows Server 2008. The next generation of virtualization or set of machines, divide into separate guest virtual is available from Microsoft with the release of Windows 7 and machines (VMs), and get more return on your investment. Server 2008 R2. There are several enhancements available, Instead of having several physical machines running around such as Live Migration, clustering support, and other features 10 percent CPU or memory resources, consolidate to a vir- that compete with VMware technology. Prior to Hyper-V, tual machine and get a better return on your investment. Microsoft released Virtual Server 2005 and Virtual PC 2007 to run on top of server and desktop platforms. These are available There are other benefits to server virtualization. It helps com- at no cost and can be downloaded from Microsoft's website. panies manage their servers better and become more efficient For more information about Hyper-V, check out www.microsoft power users and users of data center space. I’ve experienced .com/windowsserver2008/en/us/hyperv-r2.aspx. running dozens of VMs on a few host machines. The per- formance was practically the same as in a non-virtualized In addition to VMware and Microsoft, other virtualization environment. Imagine if you were the server administra- alternatives are available. Here are a few vendors’ websites tor having to maintain BIOS updates, wiring, and power for you to check out: management to dozens of machines instead of a handful of • IBM: www-03.ibm.com/systems/virtualization machines acting as host machines. I’d rather support a hand- • Citrix XenServer: www.citrix.com/English/ps2/products/ ful of host machines and several guest VMs. feature.asp?contentID=1686939 • Linux Virtual Server: www.linuxvirtualserver.org Industry leaders have a number of different points of view • Sun Microsystems Virtualbox: www.virtualbox.org on virtualization. DiscountASP.NET's Eto says, “We have taken advantage of virtualization in some parts of our host- For smaller companies that are focused on just making things ing platform. For example, our UK ASP.NET hosting infra- run, I’d encourage your IT staff to investigate virtualization structure is powered by DELL servers, NetApp SAN storage not only on the server side but the desktop as well. Being solutions, and VMware virtualization solutions.” Kingsley of able to test applications in a controlled environment can help ORCSWeb.com says his company has moved to a Microsoft stabilize your desktop. For medium to large enterprises, the Hyper-V solution. “We did virtualization at the early stages use of virtualization can help in many areas. Hyper-V is a of that market when ESX was in version 1.0. But it wasn’t serious contender and worth evaluating for Microsoft shops. stable enough for the type clients we host. Currently we have a decent size VI client base and a quickly growing Cloud computing and SaaS use virtualization for dynami- Hyper-V client base.” cally allocating resources. From the trends I’m noticing, the goal would be to run the entire data center, or as much of it VMware is a leader in the virtualization market. They offer as possible, using virtualization. Doing so will help expand many options, among them ESX Server, VMware Worksta- support for SaaS and cloud computing. tion, and VMware Server. VMware server is available for free and runs on top of Windows or Linux servers. For companies looking to get started using virtualization, using SaaS provides functionality so that a company and its VMware server is a nice, low-cost, easy way to get started. developers can consume services when needed. Contractual arrangements for SaaS can be on a short-term basis. Since I’ve used virtualization for several projects. One of my the service is consumed, licensing can be per connection, favorite features of virtualization is the snapshot fea- per user, or another flexible type of licensing. ture. Snapshots are point-in-time versions of your virtual machine; if you want to revert, it’s easy to do so. I'd load Cloud computing and virtualization are key components to my base machine, create a snapshot, install a few more having SaaS applications available. For a vendor providing programs, perform some testing, snapshot the machine, an SaaS application, it would need to have the infrastruc- load a few more programs, and perform more testing. If ture available to support dynamic growth. appliedi.net's there was an issue, I could easily go back to a prior state Coburn says that “cloud application frameworks would be and start over instead of reloading a machine from scratch. those offerings provided by the likes of Microsoft’s Azure, Virtualization provided a fast, easy way to spin up serv- Google Apps, and even Salesforce, where you build your

58 November 2009 | www.DevProConnections.com

RequiredReading Web Hosting Industry Trends entire application around their framework and run it on Advertising Index their cluster of computing resources.”

Advertiser Page URL Salesforce.com and Google are a couple of examples of companies that put cloud computing and SaaS together to Altova 13 www.altova.com provide services. When visiting the salesforce.com homep- Aspose 3 www.aspose.com age, you can see that they offer three flavors of cloud ceTe Software Cover 3 www.cete.com services: Sales Cloud, Service Cloud, and Custom Cloud. I haven’t used their services, so I can’t objectively give an DevConnections 21, 29, 35 www.devproconnections.com opinion. Google Docs is another example of this phenom- Developer Express 10 www.devexpress.com/crossword enon. Google is definitely trying to expand beyond being a discountASP.net 57 www.discountasp.net/aspnetprodeal leader in search technologies with Google Docs. dtsearch Desktop 40 www.dtsearch.com

For smaller companies, using SaaS can be a great way to sim- InfoSoft Global (P) Ltd. 41 www.fusioncharts.com/in/pro plify licensing, software maintenance, and getting what you Infragistics 17 www.infragistics.com/killerapps need, when you need it. For medium to larger companies, using the SaaS model can be trickier to integrate into the Software FX Cover 4 www.softwarefx.com corporate environment. Since most of the application require- SQL Server Magazine 46 www.sqlmag.com ments need to run locally, depending on a third-party service Syncfusion 9 www.syncfusion.com can be an issue. Time will tell if SaaS becomes the standard way of accessing applications, data, and other services. Telerik Cover 2,1 www.telerik.com/web-testing-tools Text Control 7 www.textcontrol.com Other Trends Visual Studio Launch 4, 5 www.DevConnections.com The industry experts I talked with also keep an eye on other Conference and Expo trends, such as the releases coming from Microsoft. The “full- fledged” release of ASP.NET 4.0 is just around the corner. webhost4life 59 www.aspnetpro.webhost4life.com A key trend to watch is the way Microsoft is working more closely with the open source community. For example, the IIS DevConnections (formerly asp.netPRO) is published monthly by Penton Media, team has released various modules aiming to have better sup- Inc. DevConnections, 221 E. 29th St., Loveland, CO 80538. (800) 621-1544 or (970) 663-4700. Advertising rates furnished upon request. port for PHP in IIS 7. Microsoft adopted a strategy in IIS 7 to Basic one-year subscription rates: U.S. $34.99, Canada $44.99, all other coun- tries $79.99, must be prepaid in U.S. dollars drawn on a U.S. bank. Printed in the release more “out-of-band” modules. These individual modules USA. For subscription and address changes, call (800) 650-1804 or (970) 663-4700. expand the functionality, so you don’t have to wait for major POSTMASTER: Send address changes to DevConnections, 221 E. 29th St., Loveland, CO 80538. Post International Publications Mail Product (Canadian Distribution) OS releases. I don’t know the adoption rate of open source Sales Agreement No. 40028783. Code listings may be downloaded from the DevConnections Web site at www. technologies on a Windows platform, but I can see that Micro- DevProConnections.com. Penton Media, Inc. assumes no responsibility whatsoever soft is aggressively trying to change perception in the developer for the uses made of any software code in this issue, whether modifi ed or not. Penton Media, Inc. will not be liable for special, incidental, consequential, indirect, community when it comes to integrating with traditional open or other similar damages, even if we have been advised of the possibility of such damages. In no event will our liability for any damages to you or any other person source technologies such as PHP and MySQL. ever exceed the price paid for your subscription to DevConnections, regardless of any form of the claim. Editorial contained within does not necessarily refl ect the opinions of Penton Media, Inc. Penton Media, Inc. assumes no responsibility for For more information about new IIS 7.0 modules, visit the offi- the products or services advertised within this publication. Copyright©2009 Penton Media, Inc. All rights reserved. No part of this publica- cial IIS community website at www.iis.net/extensions. tion may be reproduced in any way without the written consent of Penton Media, Inc. DevConnections is a publication of Penton Media, Inc. and is not sponsored by or affi liated with Microsoft Corporation. Microsoft is not responsible in any way for The Future the editorial policy or other contents of this publication. DevConnections is a trademark of Penton Media, Inc., Loveland, Colorado. The trends discussed in this article are helping shape what Microsoft and Visual Basic are trademarks of Microsoft Corporation and some call Web 2.0. Like any business, trends in Internet DevConnections is used by Penton Media, Inc. under license from owner. Windows is a trademark of Microsoft Corporation. All other products mentioned within are hosting will come and go until things evolve to a more trademarks of their respective owners. Microsoft, Visual Basic, Visual Studio, MSDN, ASP.NET, and the Visual Studio, mature state. Although the Internet recently celebrated its .NET, Microsoft Offi ce, and Visual Basic Logos are registered trademarks or trade- 40th birthday, changes and new things are alive and well in marks of Microsoft Corporation in the United States and/or other countries and are used by LICENSEE under license from owner. this business sector. We welcome your comments and suggestions about the content of DevConnections, as well as your commentary on the subject of ASP.NET develop- ment. We reserve the right to edit all submissions. Letters should include your name and address. Please direct all letters to [email protected]. Developers interested in publishing articles in asp.netPRO are encouraged to Steve Schofield has been a senior systems administrator for a contact Sheila Molnar at [email protected] or Anne Grubb at agrubb@penton. com. For direct mailings/e-mailings to our subscriber list please contact Walter Karl, Windows-based hosting provider. He had one of the first websites to Inc. 2 Blue Hill Plaza, 3rd Floor, Pearl River, NY 10965, Marie Briganti (845) 732- run ASP.NET in production. He was an ASP.NET MVP from 2002 to 7054, Rosalie Garcia (845) 732-7027. To obtain multiple reprints of articles in DevConnections or at www. 2006 and has been an IIS MVP since 2006. He’s currently a senior DevProConnections.com, contact Diane Madzelonka at (216) 931-9268 or via e-mail at [email protected]. support specialist for a large Midwest company.

60 November 2009 | www.DevProConnections.com NewProducts By Anne Grubb Send new product announcements to [email protected].

Intersoft Solutions Releases WebUI Studio 2009 ntersoft Solutions announced the official release of suite of data visualization components for Silverlight that IWebUI Studio 2009, a presentation layer toolkit for provides design-time support for Microsoft Expression Microsoft ASP.NET and application Blend 2 and Visual Studio 2008, and WebTextEditor, a busi- development. This release delivers nine new products and ness-oriented text editor to help developers build content includes new features designed to address demanding web management systems. application requirements, accelerate the development cycle, and improve productivity for developers and end users.

Two notable features in the product are ClientBinding and SmartBatchUpdate. According to Intersoft, ClientBinding slashes the client footprint by over 90 percent and allows data easy access to web services with just one line of markup. ClientBinding supports a variety of data providers, including Web Services, WCF Services, Microsoft ADO.NET Data Services, and cloud computing services such as Win- dows Azure and also fully supports all existing WebGrid features.

SmartBatchUpdate facilitates data editing by eliminating the many client–server update round trips required for each edit. It intelligently manages editing information on the cli- ent side and later submits it to the server in a single AJAX request, to maximize client resources and improve the edit- Three editions of WebUI Studio 2009 are available: Pre- ing experience through increased performance. mier edition (starts at $1,599); ASP.NET edition (starts at $1,299); and Silverlight edition (starts at $799). For more The WebUI Studio 2009 release also includes Presenter, a information, go to www.intersoftpt.com/WebUIStudio.

ComponentOne Launches OLAP for WinForms omponentOne has released ComponentOne OLAP for The suite provides a drag-and-drop UI for defining custom CWinForms, a suite of five Microsoft .NET Framework– views. Users may perform ad hoc analysis by selecting data based controls that provide analytical processing features fields they want to analyze, and the ComponentOne OLAP similar to those found in Microsoft Excel Pivot Tables and controls summarize the data. Pivot Charts. This new data analysis tool provides an OLAP engine that summarizes raw data according to user-selected “Users can integrate ComponentOne OLAP for WinForms criteria. into their [UI], making it compact and offering great cus- tomization,” said Gustavo Eydelsteyn, managing director at ComponentOne. “Being able to transform raw data into visible patterns and trends without writing a single line of code offers significant time savings and eliminates human error often associated with this task.”

DevConnections | November 2009 61 NewProducts

Writing a custom application to summarize data without views. By extending the PrintDocument class, it provides OLAP for WinForms requires extensive maintenance time to properties for specifying content and formatting for show- add new views, and only the originally implemented views ing OLAP grids, charts, and the raw data used to create the are available to users. OLAP for WinForms delivers a multi- report. Users can change the page orientation and print or tude of dynamic views without the need to write any code. export the report to PDF. For more information, to down- OLAP for WinForms provides summary views in the grid load a full-feature trial version, or to purchase the product, and chart and also creates printable reports based on those go to www.componentone.com.

Pitney Bowes Business Insight Releases MapInfo MapXtreme 7.0 itney Bowes Business Insight, a provider of location access virtually any data source and provide flexible spa- Pand communication intelligence software, data, and ser- tial processing capabilities vices, announced the release of MapInfo MapXtreme 7.0, • advanced analytics and spatial capabilities through grid an SDK that supports the development of map-centric and processing support map-enabled applications for the desktop and the web. • support for “M” (measurement) values to assist develop-

Designed for use by Microsoft .NET developers, MapInfo MapXtreme 7.0 provides a .NET mapping engine that’s scal- able and easy to integrate with existing systems and appli- cations. MapInfo MapXtreme 7.0 supports industry-standard data access systems and protocols, such as Oracle and Microsoft SQL Server and also supports Open Geospatial ers in delivering Linear Referencing Systems and similar Consortium WMS, WFS and GML capabilities. capabilities • enhanced support of spatial databases with full read/ Applications developed in MapInfo MapXtreme 7.0 allow write support for Microsoft SQL Server Spatial organizations to visualize and analyze data, enabling them • improved support of international deployments through to discover new relationships and trends not apparent when the MapInfo MapXtreme Localization Kit viewing data on spreadsheets and reports. Among the key new features are these: For more information, visit www.pbinsight.com. • an enhanced data provider model, enabling developers to

Red Gate Acquires {smartassembly} ed Gate Software, a provider of .NET, SQL Server, and enables developers to optimize .NET assemblies for better RMicrosoft Exchange development and administration deployment, protect intellectual property, minimize distribu- tools, announced that it has acquired {smartassembly}, tion size, increase performance, and add error-tracking and a .NET develop- debugging capabilities to applications. ment tool for software opti- “{smartassembly} has a well-deserved reputation for doing mization and exactly what it promises to do right out of the box,” said protection. The Charles Brown, manager of Red Gate’s .NET Tools Division. tool will continue to be available on the {smartassembly} “It fits Red Gate’s ‘ingeniously simple tools’ ethos perfectly. website, www.smartassembly.com. We are proud to serve the .NET community by continuing the development of this valuable tool.” For more informa- {smartassembly} provides a comprehensive feature set that tion, visit www.red-gate.com.

62 November 2009 | www.DevProConnections.com JetBrains Offers Beta Version of New Bug and Issue Tracker etBrains, a creator of intelligent, productivity-enhancing out to change that and ended up with a fast, intuitive tool Jdevelopment tools, has released YouTrack 1.0 Beta, the that’s friendly to both developers and casual bug reporters.” company’s new bug and issue tracking system. Inspired to reduce the amount of time developers spend on issue track- YouTrack features include bug reporting with a single ing, JetBrains designed a web-based, keyboard-centric issue shortcut from anywhere within the product; a query-based tracker to help its own developers and other development search capability with auto-completion and highlighting; teams process bugs and requests faster and more easily. intuitive commands to quickly execute batch operations on selected issues; a natural-language–like query and com- “As developers and users of our own products, we’d grown mand syntax; extensive keyboard support for creating, unhappy with how long it took to report and process bugs editing, and navigating between issues easily; and an AJAX- with existing based UI for fast issue handling. issue-tracking systems,” said The public release of YouTrack 1.0 is scheduled for late Vadim Gurov, 2009. Learn more about YouTrack 1.0 Beta and download it YouTrack team at www..com/youtrack/?yt_pr10b_en. lead. “We set

Stimulsoft Announces New Version of Reporting Tools for .NET, Web, and WPF timulsoft, a provider of business intelligence Sand reporting tools, announced the release of version 2009.2 of its reporting products, Stimulsoft Reports.Net, Stimulsoft Reports. Web, Stimulsoft Reports Designer.Web, and Stimulsoft Reports.Wpf. The line of tools can be used for rendering reports on different plat- forms: Stimulsoft Reports.Net generates reports from various data sources and can be used in Windows Forms and in ASP.NET, Stimulsoft Reports.Web creates web-based reports, Stimul- soft Reports.Wpf creates applications based on Windows Presentation Foundation (WPF), and Stimulsoft Reports Designer.Web is a report designer for web-based reports. Cross-Tab type of data source and new total functions Among the new features in Stimulsoft Reports.Net are (SumTime, AvgTime, MinTime, and MaxTime) these: • ability to save reports in encrypted format • new exporting functions: Export to Scalable Vector • numerous bugs from the previous version Graphics (SVG) and Microsoft PowerPoint • addition of a new Royal Mail 4-State barcode capability For more information about additional new features in the • a new StyleDesigner.exe tool latest version of Stimulsoft’s reporting products, go to www • new Report Dictionary functions, such as a Data from .stimulsoft.com/default.aspx?lang=EN.

DevConnections | November 2009 63 BackdrafBy Jonathant Goodyear

Making History with the Visual Studio Historical Debugger

y now you’ve already been welcomed to the new Microsoft has outdone itself with the new debugging fea- DevConnections. The change is bittersweet for me. tures in Visual Studio 2010. I’m most excited about the BOn one hand, I’ve been writing the Backdraft col- Historical Debugger, msdn.microsoft.com/en-us/library/ umn since the first issue of asp.netPRO (outlasting three dd264915(VS.100).aspx. Think of it as a combination of previous editors in chief) and have grown quite attached an airline black box and a digital video recorder (DVR) for to the way things were. On the other hand, the size of the Visual Studio. For the black box part, Visual Studio records .NET ecosystem has increased exponentially over the years, debug data about your application’s state as you debug it. so it’s nice to have the freedom to discuss other interesting Depending on your preferences, it can log as little as major topics. Many of us do a lot more than just ASP.NET and diagnostic events and as much as every method entry point. Silverlight development. Obviously, the more you record, the larger your log file.

Remember when the big debate was the choice between C# Visual Studio now becomes like a DVR, allowing you to and Visual Basic? Eventually, most people came to realize replay events in your debugging session to narrow down that the power is more in the .NET Framework than in the where a bug is occurring. You don’t have access to all the language used to manipulate and glue it together into solu- debugging data that you do with live debugging, but it’s a tions. I tested that theory out recently when I downloaded the fairly large subset of the essentials such as parameter val- MonoTouch framework to give it a test drive (see monotouch ues, locals, the Watch window, and the call stack. This can .net.) MonoTouch is a new part of the cross-platform save countless hours of restarting your debugging session. .NET implementation project. It enables you to build iPhone and iPod Touch apps using C# instead of Apple’s native If that were all that the Historical Debugger did, I’d be happy Objective-C language. (I hope that Microsoft puts out a com- as a clam. It does much more, though. Have you ever had pelling software development story with Windows Mobile 7 a situation where your QA team finds a bug, but it’s very next year, but for now, iPhone is where it’s at.) hard to reproduce? This can drive both development and QA crazy! With Visual Studio 2010, you can solve this problem Wiring Cocoa (Apple’s UI framework) elements together with by having your QA team use the new Test and Lab Man- C# is fairly straightforward. But I’m much less productive ager in Visual Studio Team Test 2010. Test and Lab Manager than I am while building Windows and web applications on records debug data that can be attached as .tdlog files to the Microsoft stack. It’s because MonoTouch only works with work items in Team Foundation Server. When that non- the Macintosh version of MonoDevelop (Mono’s software reproducible bug happens again, your QA team will have it development environment). Although MonoDevelop has captured on “candid camera,” and development can load the some useful Visual Studio–like features such as IntelliSense, log file containing it into the Historical Debugger for analysis it falls short of the sophisticated productivity features that and (one would hope) resolution. Visual Studio offers. I discovered that it’s not the language you use or the framework you use it on. Rather, the develop- As a final juicy nugget, because Visual Studio 2010 allows ment environment is where the productivity gains are really for multi-targeting (compiling for multiple different ver- made, and Microsoft is the undisputed leader in that category. sions of the .NET Framework), the Historical Debugger can debug applications built as far back as .NET 2.0! This fea- The feature that MonoDevelop is missing (in the context of ture alone is worth the price of admission for Visual Studio MonoTouch) is an active debugger. You can do only native 2010. debugging, and that’s just viewing the values of memory registers. It’s awesome if you know how to interpret that data. Alas, I don’t. As I’ve observed before, over half of the Jonathan Goodyear ([email protected]) is president of APSOFT, an average developer’s time is spent debugging, so it (in my Internet consulting firm in Orlando, Florida. He is Microsoft Regional opinion) is the single most important feature of any soft- Director for Florida, an ASP.NET MVP, a Microsoft Certified Solution ware development environment. Developer, and a contributing editor for DevConnections.

64 November 2009 | www.DevProConnections.com DynamicPDF…Proven .NET Components for Real-Time

Easy-to-use Highly efficient Industry leading support Huge feature set

Try it FREE today! Layout reports in DynamicPDF Designer with its Visual Studio look and feel. Experience our fully functional, never expiring evaluation and community editions. DynamicPDF Generator v5.0 for .NET Linearize/Fast Web View JavaScript DynamicPDF Suite v5.0 for .NET Encryption/Security PDF/X-1a ICC Profiles Our easy-to-use tools integrate with ASP.NET Interactive Form Fields Flexible Templates and ADO.NET allowing for the quick, real-time Over 50 Ready-To-Use Page Elements Including generation of PDF documents and reports. 20 Bar Codes and Charting Digital Signatures For easy maintenance and deployment, our most popular tools are now available as a bundled suite. DynamicPDF Merger v5.0 for .NET Merge Stamp Append Split Password/Security Form-Fill Outline and Annotation Preservation Place, Rotate, Scale and Clip Pages Decryption

DynamicPDF ReportWriter v5.0 for .NET GUI Report Designer Event Driven Recursive Sub-Reports Use PDF Templates Automatic Pagination Placeholders Record Splitting and Expansion Column Support Full DynamicPDF Merger and Generator Integration

Our Enterprise Editions now include DynamicPDF WebCache and FireMail.

ceTe Software has been delivering quality software applications and components to our customers for over 10 years. Our DynamicPDF product line has proven our commitment to delivering innovative software components and our ability to respond to the changing needs of software developers. We back our products with a first class support team trained to provide timely, accurate and thorough responses to any support needs. Data visualization for every need, every platform.

Visual Studio WPF / Silverlight Visual Studio stands today as Windows Presentation Foundation the de-facto IDE standard for (WPF) and Silverlight are the next- .NET developers. For over 15 years, Software FX generation .NET based presentation has specialized in enterprise-grade data systems for building Web based and Smart visualization solutions. Regardless of the Visual Client applications with visually stunning Studio version you are using, you can bet we experiences. Our smarts, visuals and user have the right data visualization product for your interface innovations unleash new ways of development needs! exploring and analyzing enterprise data.

Java SharePoint As the industry standard for SharePoint is quickly becoming implementing SOA and next- the knowledge capital of enterprise generation web applications, data and business intelligence for Java is the most prevalent language organizations for all sizes. Software FX among enterprise developers. Software FX brings its award-winning technology into the provides developers an in-the-box solution with SharePoint market and providing state-of-the- a wide variety of controls, including charts, art data visualization solutions along with maps, gauges and statistical functionality that training services that integrate directly into can be easily integrated to a wide variety of Java SharePoint portals. technologies.

COM PowerShell Visual Basic, C++ and ASP Windows PowerShell is continue to be the preferred quickly becoming the platform for millions of developers preferred command-line shell for worldwide. While most companies have IT professionals for easily controlling system abandoned the COM market, Software FX administration and accelerating automation. continues to advance in it, providing up-to-date With PowerGadgets, IT professionals can now data visualization components for leading create gadgets that consume and display data COM-based tools and technologies for Internet from any data source such as WMI, Exchange and client-server applications. and SQL, without the need for coding, compiling or complex development environments.

SQL Server As a key component of SQL Server 2005, Reporting Services is a platform with a comprehensive environment for authoring, managing, and delivering reports. Software FX leverages SSRS Custom report items with server controls that can be easily embedded and customized providing additional dashboard and KPI elements in your enterprise-level reports.

To master the art of data visualization, you must seek out the leader. For almost two decades, Software FX has risen above all others by bringing top-of-the-line data visualization tools to enterprise developers working with diverse markets, platforms and environments. This wisdom has evolved into a vast body of products for a vast number of platforms, including Chart FX and Grid FX which provide best-of-breed solutions for developers seeking enterprise quality and performance. For a world of data visualization products that can raise your work to a higher level, depend on the source that’s clearly on top.

SQL Server http://www.SoftwareFX.com © 2009 Software FX, Inc. All Rights Reserved. Chart FX, Grid FX and PowerGadgets are registered trademarks of Software FX, Inc. DataParts is a trademark of Software FX, Inc. All other names are trademarks or registered trademarks of their respective owners. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.