Workflow is one of the new core capabilities (along with WPF aka Avalon and WCF aka Indigo) being added in the .NET Framework 3.0 release later this year. It provides an in-process workflow engine to process rules, a designer for VS 2005 to enable both developers and non-developers to define custom workflow processes graphically, and a new Workflow namespace to integrate these within code. The official site to learn more about Windows Workflow Foundation can be found here.
September 3rd Update: I just stumbled upon an awesome XNA tutorial site that includes a lot of great tutorials on how to get started with the XNA game framework. This tutorial, for example, walksthrough all of the code needed to build the classic Pong game with it. And this tutorial talks about how to customize the "Spacewar" starter kit.
One of the highlights for me of my recent trip to TechEd NZ and Australia was the opportunity I had to create and present a new "Building Data Driven ASP.NET Web Applications using LINQ" talk. LINQ is a super cool new technology, and is going to have an absolutely enormous impact on .NET developers and how they use data. I had a lot of fun doing the talk, and people seemed to really like it (someone told me just before I flew back that it was the most highly rated talk at TechEd this year).
Many thanks to everyone in New Zealand who attended my "ASP.NET 2.0: Tips and Tricks" talk this morning.
The Internet Explorer team maintains a really good blog here: http://blogs.msdn.com/ie that I recommend subscribing to for useful information.
Many thanks to everyone in New Zealand who attended my "ASP.NET: End-to-End - Building a Complete Web Application Using ASP.NET 2.0, Visual Studio 2005, and IIS7 (Parts 1 and 2)" talk this afternoon.
While procrastinating from finishing up my TechEd talks in my hotel room here in NZ, I came across this really funny link of a Microsoft UK employee's "Ten Worst Presentation Moments" that had me laughing out loud.
One scenario that many large development teams often ask me about is whether it is possible to split up/partition an ASP.NET web application into multiple projects within Visual Studio. The goal with doing this is typically to improve the modularity of large sites and/or to improve the IDE compile-time performance for large projects.
Earlier this week the Windows Live team released the new Windows Live Writer blog posting and management tool that you can download and use for free. It is a desktop application that provides a really nice editing environment for writing blog posts (spell checker, layout manager, offline editing support, etc).
I’m about to take off for a whirlwind business trip the next 10 days – and email and blog comment responses will unfortunately be very slow while I'm away.
I’ll be traveling to New Zealand and Australia for their TechEd events next week. I’m doing 1 keynote presentation, 2 panels, and 8 breakout talks next week – which leave me fairly busy.
My last talk is from 9:00-10:30am next Friday in Sydney, at which point I jump in a cab and head to the airport for a 2pm flight to San Francisco. Because of the time-change I get to go back in time, and actually arrive at 10am the same day. I’m then getting a rental car and driving north to Sebastopol (in Marin County) for Tim O’Reilly’s FOO camp event over the weekend. I then fly home on the Sunday.
Please forgive any delays in me getting back to you while I’m away – it is going to be a pretty busy trip!
P.S. If you are attending TechEd New Zealand or Australia, definitely stop by and say hi. I've never been to either country and am really looking forward to visiting.
Problem: You are developing/maintaining an ASP.NET web-site, and would like the ability to conditionally show/hide runtime error messages depending on who the user visiting the site is.
For a normal user visiting the site you want to be able to display a friendly error message like this when a runtime error occurs:
But when someone within the “developers” security role of your application remotely accesses the site you want to instead show a more detailed exception stack trace error message about the problem without having to change any configuration data:
The below post describes how to use ASP.NET’s role-based security architecture in conjunction with the Global.asax Application_Error event handler to enable this. You can also download a sample I’ve built that shows how to implement this here.
Some Background Discussion on Error Handling and ASP.NET Custom Error Pages:
ASP.NET and .NET support a rich error-handling architecture that provides a flexible way to catch/handle errors at multiple levels within an application. Specifically, you can catch and handle a runtime exception with a class, within a page, or on the global application level using the Application_Error event handler within the Global.asax class. If a runtime exception isn’t handled/cancelled by one of these mechanisms, then ASP.NET’s Custom Error Page feature will kick-in, and an error page will be sent back to the browser accessing the application.
ASP.NET’s Custom Error Page feature can be used to configure a “friendly error page” to be displayed to end-users in place of the standard “server error occurred” message sent back by ASP.NET. For example, the below web.config file section will cause remote users visiting the site to be redirected to a “friendlyErrorPage.htm” file anytime a runtime error occurs (note: HTTP 500 status code responses indicate runtime errors on the server):
<error statusCode="500" redirect="friendlyErrorPage.htm"/>
To learn more about how the ASP.NET Custom Errors feature works, and how to configure it, please review this article.
Important: I would recommend never setting the <customErrors> mode attribute to “Off”. Doing this will cause detailed error messages to be sent back to all normal users visiting your site. This can lead to information disclosure issues that can compromise the security of your site. Instead, only change this setting to “On” or “RemoteOnly” (the default) and use the technique below for cases where you want to display detailed error messages to only some users.
The above <customErrors> configuration section will cause a friendly error message to be sent to the browser anytime a runtime error message occurs. This is what we want to happen anytime a normal user access the site, and will allow us to display error pages like this:
To enable developers to instead see detailed error messages when they access the site, I can then add this code to the Application_Error event handler within the Global.asax class:
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
If (Context IsNot Nothing) And (Context.User.IsInRole("Developer")) Then
Dim err As Exception = Server.GetLastError()
Response.Write("<h1>" & err.InnerException.Message & "</h1>")
Response.Write("<pre>" & err.ToString & "</pre>")
The above code checks to see if the current user visiting the site is within a specific security role. If so, then it retrieves the exception raised during the current request via the Server.GetLastError() method. It then clears out any content already generated during the current request, and instead outputs the Exception details to the response. Lastly, it clears out the Exception from the request – which will prevent ASP.NET’s custom error architecture from kicking in. The result instead is a page that details the error like so:
To learn more about how you can easily create and manage a “Developer” role like the one I’m using above, please review my previous post: Implementing Role Based Security with ASP.NET using Windows Authentication and SQL Server. If you don’t want to store your role-mappings within a database, you can also store them within Active Directory or your own custom role-provider.
This sample demonstrates using a Windows User’s membership within the local “Administrators” group on a machine to control whether or not the detailed error message is displayed. Note: you can perform a role-check on a local Windows group by writing: User.IsInRole(“BUILTIN\Administrators”) – where the “BUILTIN” prefix indicates that it is a local group as opposed to a domain level one).
Hope this helps,
P.S. Please visit this page to read more articles within my “ASP.NET 2.0 Tips/Tricks/Recipes and Gotchas” series.
Below are some nice articles and links I’ve found on the web over the last week that I enjoyed, and recommend setting aside some time to consider reading:
Sending Email in ASP.NET 2.0: This is a great article from Scott Mitchell that demonstrates how to use the new System.Net.Mail APIs in .NET 2.0 to send email from an ASP.NET application.
Sending Email in ASP.NET 2.0: HTML-Formatted Emails, Attachments, and Gracefully Handling SMTP Exceptions: This is a great follow-up article on email from Scott Mitchell that discusses some more advanced email scenarios using System.Net.Mail.
UrlRewritingNet.UrlRewrite V2.0 Released: Albert Weinert sent me mail on Friday pointing me at the new release of the UrlRewriting engine that he and Thomas Bandt wrote for ASP.NET. It is available as a free download and includes samples + full source code.
Working with GridView Without Using Data Source Controls: There are lots of good articles out there on how to use the new ASP.NET 2.0 GridView control with the ASP.NET 2.0 data source control model. In this article Bipin Joshi covers how to program against the GridView directly without using DataSource controls (and instead write code directly to handle binding, paging, sorting, etc).
Using FlickR with .NET: This article by Sam Judson discusses how to consume and use the FlickR photo-service APIs within a .NET application. This allows you to build your own photo browsing applications, as well as upload content programmatically against Yahoo’s FlickR service.
Accessing Embedded Resources through a URL using WebResource.axd: ASP.NET 2.0 introduced a really useful feature called “WebResource.axd”. This enables you to avoid having to manually deploy script and image resources files in well-known directories (no more /aspnet_client/ virtual directories). In this article Scott Mitchell discusses how it works, and how you can use this feature yourself to embed file resources within your own controls and components.
ASP.NET Case Study: Lost Session Variables and AppDomain Recycles: Tess continues her awesome set of detailed ASP.NET debugging posts to delve into the mysteries of how ASP.NET App-domains work and when they recycle (and why).
VS 2005 Topics
Custom Grouping of Related Files in VS 2005 ASP.NET Projects: Visual Studio provides built-in support for nesting certain file-types under others within the solution explorer (for example: the code-behind file for an .aspx page is shown as a sub-item in the solution explorer). In this blog post James Hebben shows a neat registry trick that allows you to nest any file under another one inside VS 2005. He illustrates this with a useful sample where you could nest content-specific .js files underneath pages or controls.
MSBuild in Visual Studio 2005: This 13-part article series describes how the new MSBuild build system works in Visual Studio 2005. Note that MSBuild can be used with both VS 2005 Web Application Projects and with VS 2005 Web Deployment Projects.
Cool Future Stuff
Windows Workflow Foundation Hello World App: Sahil Malik has posted a few cool articles that demonstrate how to use the new Workflow features that are shipping this fall with .NET 3.0. Workflow allows you to build composable sequences of operations together in a really flexible way (and allows you to avoid hard-coding in logic). This hello-world sample (and the previous post it links to) provides a quick way to learn more about the new technology.
Hope this helps,
The Arizona .NET User's Group has one really big meeting every year, and I've been fortunate to have been invited to come out and speak again for this year's event. It will be held all day Wednesday September 6th at the Orpheum theater in Phoenix, Arizona. I’ll be on stage for a little over 3 hours total, and topics I'll be covering include ASP.NET 2.0 Tips and Tricks, IIS 7.0, Atlas, LINQ/LINQ for SQL and more.
Here's where you can register to attend: http://azgroups.com/forums/post/489.aspx (the event is free).
Hope to see you there!
The Atlas team recently shipped a new Atlas July CTP that contains a number of bug-fixes. You can download it off of the http://atlas.asp.net/ web-site (like all Atlas CTPs it supports a go-live license).
The Atlas Control Toolkit team – which is building up a great library of useful Atlas-enabled controls on top of the core Atlas runtime – also recently posted a binary refresh of the Atlas Control Toolkit as well. You can read all about it in Shawn’s announcement post of it, and download it for free here.
What is really cool about this new Atlas Control Toolkit update is that it includes Atlas controls contributed by non-Microsoft developers. As I mentioned in an earlier post, we are building the Atlas Control Toolkit collaboratively with the broader .NET developer community as a free shared source project on the new CodePlex site. Our goal is to have ~50 great free Atlas controls that you can download and use as part of it by the end of the year.
There are currently 21 cool Atlas-enabled controls included within the Atlas Control Toolkit download (with many more coming soon). You can run online demos of them from the sample site here. Below is a screen-shot of the Atlas Control Toolkit samples that you can try out from this samples site online:
Some of my favorite new controls are the ones built by the non-Microsoft contributors to the project. These include the new FilteredTextBox developed by Christian Wenz that you can see in the screen-shot above. Paul Glavich built the cool new PasswordStrengthExtender control which provides real-time feedback on password complexity:
All of the controls in the toolkit are free, and all ship with full source code (including a license that allows you to take the source, modify it, and do whatever you want with it).
How to Get Started with the Atlas Control Toolkit
To learn more about the Atlas Control Toolkit and how to get started with it, visit the Atlas Control Toolkit site here. Make sure to also then check-out the Atlas video series that Joe Stagner is working on:
- Get started with “Atlas” (10 minutes, 2 seconds)
- Get started with the “Atlas” Control Toolkit (12 minutes, 9 seconds)
- Use the CascadingDropDown Control Extender (19 minutes, 9 seconds)
Note: The CascadingDropDown control video above was just posted yesterday and shows how to use this control (which ships in the Atlas Control Toolkit) to build Ajax enabled drop-downlists that depend on each other’s values and don’t require a full server round-trip to update when changed.
Hope this helps,
Several people have sent me email lately asking for a suggested short-list of my best/favorite past blog posts to read (I’ve done 200 posts over the last 12 months and apparently it takes too long to read them all <g>).
I’ve put together a summary page of ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas that you can check out here. It currently contains links to 37 posts that I’ve done in the past that I think are interesting and worth spending sometime to read.
I’ve organized the list by area topic (UI, Data, Security, Visual Studio, etc). My goal is to post at least 1-2 new/original ASP.NET Tips/Tricks/Recipes to my blog each week going forward. I’ll also make sure to update the summary page above as I add new ones – so you might find it useful to bookmark if you want to quickly look them up.
Hope this helps,
This page lists some of the more popular “ASP.NET 2.0 Tips, Tricks, Recipes and Gotchas” posts I’ve done. My goal is to add new posts to the series regularly going forward – so bookmark this page for updates, or subscribe to my blog via this RSS feed.
In addition to my articles below, I highly recommend the following ASP.NET books:
To learn more about ASP.NET, also make sure to watch all of the great “ASP.NET: How Do I?” videos (each week a new video is posted). You can also browse a large listing of other ASP.NET 2.0 books here.
Visual Studio 2005
- Tip/Trick: Optimizing ASP.NET 2.0 Web Project Build Performance with VS 2005
- Common Gotcha: Slow VS 2005 Web Site Build Performance Because of “Dueling Assembly References”
- Common Gotcha: Public Hotfix available for Slow Debugging Problems
- Tip/Trick: Changing the default browser used in VS 2005 and Visual Web Developer
- Tip/Trick: Creating Packaged ASP.NET Setup Programs with VS 2005
- Resource: VS 2005 Web Application Project Tutorials
- Recipe: Using VS 2005 Web Deployment Projects
- Tip/Trick: Custom formatting HTML in Visual Web Developer and Visual Studio 2005
- Tip/Trick: Fast HTML Editor Navigation within VS 2005
- Tip/Trick: How to Run a Root “/” Site with the Local Web Server using VS 2005 SP1
- Tip/Trick: Creating Re-Usable Project and Item Templates with VS 2005
- Tip/Trick: Creating Sub-Web Projects using the VS 2005 Web Application Project Option
- Tip/Trick: Spell Checker Plug-in for VS 2005 for ASP.NET and HTML Pages
- Tip/Trick: Using IIS7 on Vista with VS 2005
- Gotcha: Fixing Error with VS 2005 SP1 Beta and older Web Application Project Templates
- Tip/Trick: Enabling URL Rewriting with ASP.NET
- Tip/Trick: Using Server Side Comments with ASP.NET 2.0
- Tip/Trick: Use the ASP.NET 2.0 CSS Control Adapters for CSS friendly HTML output
- Tip/Trick: How to Register User Controls and Custom Controls in Web.config
- Recipe: Dynamic Site Layout and Style Personalization with ASP.NET
- Tip/Trick: Advanced Article on ASP.NET 2.0 Master Pages
- Tip/Trick: Handling Errors with the UpdatePanel control using ASP.NET AJAX
- Tip/Trick: Cool UI Templating Technique to use with ASP.NET AJAX for non-UpdatePanel scenarios
- Links: ASP.NET AJAX and ASP.NET AJAX Control Toolkit Articles
- Gotcha: Lost HTML Intellisense within ASP.NET AJAX Controls
- Gotcha: Don't use <xhtmlConformance mode="Legacy"/> with ASP.NET AJAX
- Tip/Trick: UpdateProgress Control and AJAX Activity Image Animations
- Tip/Trick: Nikhil's WebDevHelper Utility and ASP.NET AJAX Support
- Tip/Trick: How to Upload a .SQL file to a Hoster and Execute it to Deploy a Database
- Tip/Trick: Deploying a SQL Database to a Remote Hoster Environment
- Tip/Trick: Online Database Schema Samples Library
- Recipe: Great ASP.NET 2.0 Data Tutorials
- Recipe ASP.NET 2.0 RSS Tool-Kit
- Recipe: Paging through lots of data efficiently (and in an Ajax way) with ASP.NET 2.0
- Recipe: Efficient Data Paging with the ASP.NET 2.0 DataList Control and ObjectDataSource
- Tip/Trick: ListControl.AppendDataBoundItems Property in ASP.NET 2.0
- Resource: ASP.NET 2.0 Membership, Roles, Forms Authentication, and Security Resources
- Recipe: Enabling Windows Authentication within an Intranet ASP.NET Web application
- Recipe: Implementing Role Based Security with ASP.NET using Windows Authentication and SQL Server
- Recipe: Configuring ASP.NET 2.0 Application Services to use SQL Server 2000 or SQL Server 2005
- Tip/Trick: Integrating ASP.NET Security with Classic ASP and non-ASP.NET URLs
- Gotcha: Always set the "applicationName" property when configuring ASP.NET 2.0 Membership and other Providers
- Common Gotcha: Don't forget to <clear/> when adding providers
- Tip/Trick: Source/Documentation for Simple ASP.NET 2.0 SQL Providers Published
- Tip/Trick: Guard Against SQL Injection Attacks
- Tip/Trick: Gathering Custom User Registration Information
- Recipe: How to add a Login, Roles and Profile system to an ASP.NET 2.0 app in only 24 lines of code
- Gotcha: Authorization with the built-in VS 2005 Web Server (aka Cassini)
- Gotcha: Forms Authentication timeout default changed between ASP.NET 1.1 -> ASP.NET 2.0
- Tip/Trick: How To Share Authentication Cookies across ASP.NET V1.1 and ASP.NET V2.0 Applications
- Tip/Trick: Enabling SSL on IIS 7.0 using Self Signed Certificates
- Gotcha: Don’t run production ASP.NET Applications with debug=”true” enabled
- Tip/Trick: Automating Dev, QA, Production Web.Config Settings with VS 2005
- Tip/Trick: Creating Packaged ASP.NET Setup Programs with VS 2005
- Tip/Trick: Patterns and Practices Guidance Explorer for .NET and ASP.NET
- Tip/Trick: App_Offline.htm and working around the "IE Friendly Errors" feature
- Tip/Trick: Show Detailed Error Messages to Developers (and only to Developers)
- Tip/Trick: Logging ASP.NET Application Shutdown Events
- Tip/Trick: Implement "Donut Caching" with the ASP.NET 2.0 Output Cache Substitution Feature
- Tip/Trick: Disk Based Output Caching Feature Now Available for ASP.NET 2.0
- Tip/Trick: Cache Manager
.NET 3.5 and VS 2008
- VS 2008 Multi-Targeting Support
- VS 2008 Code Editing Improvements
- VS 2008 Nested Master Page Support
- VS 2008 Web Designer and CSS Improvements
- VS 2008 Vertical Split View Support
- VS 2008 ASP.NET AJAX Control Extenders
- ASP.NET ListView Control (Part 1: Building a Product Listing Page with Pure CSS)
- ASP.NET AJAX in .NET 3.5 and VS 2008
LINQ and .NET 3.5
- LINQ to SQL (Part 1 - Overview)
- LINQ to SQL (Part 2 - Defining our Data Model Classes)
- LINQ to SQL (Part 3 - Querying our Database)
- LINQ to SQL (Part 4 - Updating our Database)
- LINQ to SQL (Part 5 - Binding UI using the asp:linqdatasource)
- LINQ to SQL (Part 6 - Retrieving data using stored procedures)
- LINQ to SQL (Part 7 - Updating our database using stored procedures)
- LINQ to SQL (Part 8 - Executing Custom SQL Expressions)
- LINQ to SQL (Part 9 - Using a Custom LINQ Expression with the <asp:LinqDataSource> control)
- LINQ to XML (How to Build a Custom RSS Reader with it)
- New Language Feature: Automatic Properties, Object Initializer and Collection Initializers
- New Language Feature: Extension Methods
- New Language Feature: Lambda Expressions
- New Language Feature: Query Syntax
- New Language Feature: Anonymous Types
- Recipe: Tagging Data using LINQ
- Null Coalescing Operator and using it with LINQ
- My Silverlight Overview Post
- My "Lap Around Silverlight" talk from TechEd
- Building Silverlight Applications using .NET
- Tip/Trick: Supporting Full Screen Mode with Silverlight