Web Development

On the handling of errors

I was asked recently if errors in an application should be handled in the business layer or in the UI. The answer to this is simple: Neither. Doing so is repetitive and unproductive. Error handling should be an automatic part of your infrastructure. It may seem that error handling is not something that can be performed automatically. But this is due to a broader definition of error than is applicable here. Conditions that are expected and probable during your applications execution are not errors, they’re use cases. If may be a user error that they have entered an invalid...

posted @ Saturday, February 05, 2011 12:00 PM | Feedback (0)

ASP.NET MVC doesn't like you reusing controller instances

I've learnt tonight that ASP.NET MVC tends to get annoyed when you reuse a controller instance. I have a (rather primitive) factory creating controllers and doing some simple dependency injection. This is a result of a medium trust target environment. My first pass at a controller factory reused controller instances. This resulted in InvalidOperationExceptions with the message: The parameters dictionary does not contain a valid value of type 'System.Int32' for parameter 'id' which is required for method 'System.Web.Mvc.ActionResult EditPosting(Int32)' in '<MyController>'. To make a parameter optional its type should either be a reference type or a Nullable type....

posted @ Monday, November 03, 2008 11:30 PM | Feedback (0)

Sessions are evil and other problems with making the stateless stateful

Way back in the dark ages the world wide web was created as a means of sharing static content. For various good reasons HTTP was made a stateless protocol. This conserved server resources as a client only consumed scarce resources (such as memory and network connections) during the processing of the request. As the requests are bursty this allowed many more clients to use a server than in a more traditional network application where clients have persistent connections and tie up resources for long periods.   In the beginning this was fine but as people started to use it more this became...

posted @ Thursday, January 10, 2008 2:20 AM | Feedback (0)