March 2006 Entries

Recreational Debugging

Eran Sandler runs a great ”Advanced .NET Debugging Blog”. In his recent post “Ambiguous match found in a Web Control - a Possible Bug”, Eran debugs the ASP.NET compiler to find the cause of an error message. Eran could have fixed the ambiguous match error by changing some code and moving on with life, but it’s hard to pass up a good mystery. It’s fun to figure out why someone else’s code makes our code behave the way it does. Here is a recent mystery I ran across: why does the following code invoke my workflow’s constructor twice? WorkflowRuntime runtime...

Authoring Workflows

My latest OdeToCode article, Authoring Workflows, looks at how XAML, XOML, partial classes, and compilers all work together in Windows Workflow. I appreciate any comments, suggestions, and other feedback about the article.

ASP.NET Event Validation and “Invalid Callback Or Postback Argument” : Part II

In the last post we looked at the job event validation performs, and how we can trigger a validation error with some innocent JavaScript. If we receive exceptions because of event validation, we have to disable the feature, or learn how to work with the event validation. Disable Event Validation Pros: Easy to doCons: Less secure Bertrand Le Roy wrote a post back in 2004: “Please, please, please, learn about injection attacks!”. Event validation is a feature designed to help prevent injection attacks (of course it can't prevent attacks all by itself). We can disable event validation for an entire site in the web.config...

ASP.NET Event Validation and “Invalid Callback Or Postback Argument” : Part I

ASP.NET 2.0 added a feature called event validation. Event validation checks the incoming values in a POST to ensure the values are known, good values. If the runtime sees a value it doesn’t know about, it throws an exception. Invalid postback or callback argument. Event validation is enabled using <pages enableeventvalidation="true" /> in configuration or <%@ page enableeventvalidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the...

Using ASP.NET 2.0 to Streamline Web Application Development

Microsoft released a curious case study yesterday: “Using ASP.NET 2.0 to Streamline Web Application Development”. (Be aware that if you go to read this document, it is a case study. The document is 100% buzzword complaint and strategically aligned to leverage 80% of your existing infrastructure for a 120% ROI over 2 years). First, the background section describes the problem Microsoft Human Resource IT was experiencing. Because of this lack of a standardized architecture and design between applications, HRIT experienced increased costs in application maintenance. For example, HRIT recently spent several thousand dollars over a three-month period to update the...

Boundaries Are Explicit Because Iteration Kills

Growing up with C++, I’ve always expected software to have a strong domain model. If I had grown up with ADO Recordsets or ADO.NET DataSets, perhaps I’d have a different perspective on software, but my initial reaction to the Recordset was bewilderment at an object chocked full of data and no behaviors. I can see both sides of the coin now, and I think both approaches have their advantages in different scenarios. I still prefer the domain model. I do wonder how these models will evolve over the next few years as technologies like DLINQ arrive and continue the push towards...

ASP.NET in Your Ear

Saturday was a beautiful, sunny day in Washington D.C. Unfortunately, I spent the morning working in the infamous Watergate building, but did get a chance to navigate through the pedestrian traffic at noon and meet Sir Wally McClure for lunch. Wally is a genuinely funny, smart, and friendly guy. His personality shines through during his ASP.NET Podcast, and makes the show an enjoyable listen. Wally asked me to do a quick interview, and I obliged. He posted the show late Sunday evening. I’ve been dubbed the godfather of the “world needs more Wally” meme that is all the rage.

Setting An ASP.NET Theme in the PreInit Event Handler

Let’s say I want the user to select their favorite theme for my application. I can make a list of available themes in a DropDownList control. <asp:DropDownList ID="_themeList"                   runat="server"                   AutoPostBack="True">  <asp:ListItem>Default</asp:ListItem>  <asp:ListItem>Odeish</asp:ListItem>  <asp:ListItem>Codeish</asp:ListItem></asp:DropDownList> I know I must set the Theme property before or during the page’s PreInit event. What’s wrong with the following code? protected void Page_PreInit(object sender, EventArgs e){    if (IsPostBack)    {        Theme = _themeList.SelectedValue;    }} The above code throws a null reference exception. PreInit fires before the page instantiates its controls, so _themeList is null (Nothing). I can’t use the _themeList control, but I can go directly to the Request.Form collection. The DropDownList (an HTML select) will post...

Horizontal and Vertical Coupling

One aspect of the default ASP.NET 2.0 project model I really like is how the code-beside file and the declarative markup file compile at the same time. The compilation model produces a comfortable coupling between the declarative markup and the class in the code-beside file. This is ‘vertical coupling’. The ASP.NET runtime can generate strongly typed properties for the code-beside class via the magic of partial classes. Web Application Projects for Visual Studio 2005 delivers the ASP.NET 1.1 code-behind model for ASP.NET 2.0. Many applications will have an easier migration path to 2.0 with WAP. One problem I...

Toronto!

I have three sessions to present at VSLive! Toronto (April 24 – April 27 - Toronto Congress Center). I hope to see you there.

ShowMeLife

I keep meaning to upload the source code to ShowMeLife. ShowMeLife is an application I’ve used in a couple user group talks to demonstrate Visual Studio 2005 features, like debugging visualizers. A few people have asked for the source. ShowMeLife is a Windows application that runs in full screen mode. The app displays images from Flickr. I can type in the tags I want the images to have, and the app looks for the photos using flickr.photos.search. Source code. You’ll need a Flickr API key to run the app. The API key goes into the app.config file. <applicationSettings>    <ShowMeLife.Properties.Settings>        <setting name="Flickr_ApiKey" serializeAs="String">            <value>Insert your...

New Article On Windows Workflow

Lately, I’ve been spending my evenings with Windows Workflow. Hello, Workflow is a new, feature length introduction to WinWF. The primary building block in Windows Workflow is the activity. All activities in WinWF derive from an Activity base class. Activities compose the steps, or tasks in a workflow. We can arrange activities into a hierarchy and feed the activities to the workflow engine as instructions to execute. The activities can direct workflows involving both software and humans. Read more…