The Google Closure Compiler is a great tool for minifying JavaScript – it has the ability to both minify and optimize code, with output that’s both lightweight and performant. If you’re living on the .NET stack though, the fact that it’s in Java might be an impediment to either use or integration. In this post …
Category Archives: .NET
Use build configurations to control Razor compilation
Recently Phil Haack posted an article on “Compiling MVC Views In A Build Environment”, describing how to switch on view compilation. This can be incredibly useful, surfacing compilation errors across the project rather than relying on picking it up at runtime. However, I found that it slows compilation down quite significantly. It also seems to …
ASP.NET MVC error: “The value ‘x’ is not valid for Id”
In my current project I’m using ASP.NET MVC 3 and enjoying it; kudos to Mr Haack and his minions. That said, I just had a problem that took me ages to sort out, though it is trivially simple in retrospect. I kept getting a ModelState error that ‘The value “x” is not a valid value …
Override templates in an ASP.NET MVC project
The built-in templates for ASP.NET MVC get you up and running quickly; but as you build a project it’s more productive to have it generate output that fits with your requirements, rather than the generic output that will need to be changed each time. Thankfully, this is easily accomplished by copying the default templates into …
Creating an Umbraco custom section
I needed to create a custom section for a project I am working on, which isn’t well covered in documentation, however the Umbraco community has stepped up and published some excellent guides for getting this done. Below are some links to these high quality articles, and some additional notes.
ASP.NET sites not working
I wasted a few hours tracking down an issue the other day where I couldn’t get an ASP.NET website running on a fresh install of Windows 7 and VS 2010. This website was running on my previous install, making it very frustrating. I spent a lot of time running through event log red herrings before …
Sorting with LINQ: don’t use anonymous types
I got the error message “System.ArgumentException: At least one object must implement IComparable.” today for the following, seemingly innocuous code. var ordered = order.Lines.OrderBy(l => new { l.AdminCode, l.OrderLineNr}); I thought this was the way to do it; after, that’s the way that you use Join() for multiple properties. What it was however was a …
Using asymmetric properties in views
Many people separate their business logic and view classes into two or more separate assemblies. This gives rise to the ability to use an asymmetric set for view properties that aren’t meant to be accessible. Simply put: public string SomeProperty { get; internal set; } The internal modifier means that this property is only accessible …
Google Docs API: get all spreadsheets/docs in a folder
It’s easy enough to get a list of spreadsheets for a user, or a list of folders, but there’s a trick to getting the contents of a folder. The first part of the trick is to ignore the category. Firstly, because it’s removed in version 3.0 of the API, and secondly because it filters by …
Convert file path to file URL
A very short note: I was trying to find an analogue to Java’s File.toURI().toURL() method in .NET, looking through System.IO et al, and not finding it on the lazyweb. To my surprise, all you need use is UriBuilder: new UriBuilder(@”c:\path\to\file.txt”).ToString(); This will output “file://c:/path/to/file.txt“. Simple, but far too much time wasted finding it…