Firefox 6 Infinite Page Refresh With Page With Hash Tags

Turns out, this is an issue with an old version of MicrosoftAjax.js (the one that comes installed with Asp.Net MVC 2). Open up the MicrosoftAjax.debug.js file and check the file version number. The top of this file will look like this if this is your problem: // Name: MicrosoftAjax.debug.js // Assembly: System.Web.Extensions // Version: 4.0.0.0 … Read more

Service Layer vs Business Layer in architecting web applications?

It is all about decoupling your app into self contained pieces, each one defined by the requirement to do one job really well. This allows you to apply specialised design patterns and best practices to each component. For example, the business layer’s job is to implement the business logic. Full stop. Exposing an API designed … Read more

How to concatenate several MvcHtmlString instances

Too bad C# won’t let us override the + operator here! How about using an extension method instead? public static MvcHtmlString Concat(this MvcHtmlString first, params MvcHtmlString[] strings) { return MvcHtmlString.Create(first.ToString() + string.Concat(strings.Select(s => s.ToString()))); } This could probably be optimized, but you can run with it. It should be fairly trivial to prove that this … Read more

ModelState.AddModelError – How can I add an error that isn’t for a property?

I eventually stumbled upon an example of the usage I was looking for – to assign an error to the Model in general, rather than one of it’s properties, as usual you call: ModelState.AddModelError(string key, string errorMessage); but use an empty string for the key: ModelState.AddModelError(string.Empty, “There is something wrong with Foo.”); The error message … Read more