Grand Rapids .NET User Group Presentation: Distributed .NET

Slides
The slide deck I used was a combination of decks by Clemens Vasters and Steve Swartz. While my presentation was designed to teach the patterns and language of all varieties of distributed development, theirs are focused on code and data respectively.

Clemens Vasters TechEd Presentation on Distributed .NET Apps
[Streaming Video] [Slide Deck]

Steve Swartz's TechEd Presentation on Distributed Data
[Streaming Video] [Slide Deck]

MSDN Articles. When mine they go live, they will be here, complete with source!

Source Code
The Remoting Demo was adapted from Ingo's book. [Source]

Data access code which uses the Factory Pattern to run either connected or disconnected is found in Clemens's massive distributed Northwinds demo. To run it you will also need MSDE or SQL Server with the Northwinds data, and the newTelligence SDK. You can find these (and more!) from C.V.'s TechEd Malaysia Weblog. Be sure to view the SDK's online ReadMe file, it requires you to generate your own private key and update the AssemblyInfo.cs file in each of its several Visual Studio Projects before you can Build. But it's a pretty amazing SDK.

Books
Both of the four books recommended (how's that work?) happen to be from APress, and both are available in both C# and VB versions!

Question and Answer
Question: How do you authenticate against Web Services?
Answer #1: Read up on the Web Service Enhancements (WSE). Version 1.0 makes it relatively easy to use X.509 certificates and digital signing to authenticate users, and version 2.0 lets you plug certificate-based authentication into .NET's role-based security features. This is the recommended solution for public web services.
Answer #2: Use Basic, Digest, or Windows Authentication. While not always scalable on high traffic services, simply configuring IIS or web.config to force authentication will do the trick for many enterprises. Web services run on ASP.NET just as web pages do so you can require users to authenticate just as you would on an Intranet. Then all you need is HttpContext.Current.User.Identity.Name or User.IsInRole() to identify the logged in user just the same.

Question: How do you share Session information across Applications? The primary purpose is to have a single login across sites or VS Projects. Is there a remoting solution?
Wrong Answer: Write a class and store it in the Global Assembly Cache where all the applications can see it. The GAC allows apps to share assemblies, but does not provide shared memory. This won't work.
The Answer: The point of managed code is to keep applications running independent of each other. Remoting provides a way to give an applicaton a surface or interface, but for this purpose you really need a central store, not a peer-to-peer application model. You're going to need to either write a Service (Web or Win, both would work) or a Shared Assembly that all the apps have access to (preferably installed to the GAC) for consistency and ease of deployment) , and store the data somewhere. A database with proper locking (MySQL or SQL Server) would be best. The key is to think of it as a central data store, whichever surface you put on it is up to you.

Question: How do you send data to Excel (seen in a demo after the presentation)?
Answer: The easiest method is to build a page that puts your data in a DataGrid and then rewrite the MIME-headers so the browser thinks an Excel file is on the way. Excel imports the DataGrid's HTML table with ease, formatting intact. The best resource is by Dipal Choksi, who goes as far as to programmatically remove ViewState and page controls that Excel might not like. This is awesome if you want to apply the trick to your existing DataGrids (i.e. if you're too lazy to write a separate page for the purpose). [Article and Source]

Software
The awesome Explorer replacement you saw was Total Commander by Christian Ghisler. It also does FTP, folder synchronization, bulk renaming, treats zips and other archives just like folders (create, add, rename, etc.), and does a thousand other things. You won't know how you lived without it. It nags to register on startup and stays quiet thereafter. You'll want to register (I did in the mid 90's), this is one you will use for years.

The great web browser was Opera 7.11. If you design web pages, try it. Open the Keyboard Help and check out the great display features (G, Ctrl-G, and Shift-G are my favourites. Shift-F11 makes it pretend to be a PDA. F11 Full-screen mode kicks) . Learn its mouse gestures (never reach for the Back / Minimize / Close buttons again). Check out its F12 Quick Preferences (turn javascript popups on or off in 2 clicks, or identify yourself as MSIE or Mozilla at will). Opera rocks.

Thanks Again
I had a great time talking about Distributed .NET in Grand Rapids, thanks again! If there is anything else you would like to see here (related to the presentation), just drop me a line.

No Comments