SmoothFriction.nl

posts - 39, comments - 20, trackbacks - 0

October 2009 Entries

Introducing .less, goodbye to Less.NET

As some of you might know, I’ve been diligently working on the C# port for the 'funky' ruby gem, {Less}. Well, we merged the nLess and Less.NET groups, creating .Less, and we’re live! We support the main {Less} specs, up to version 1.2.0 if I am correct. Here’s a quick synopsis, taken from our main site: Variables Variables allow you to specify widely used values in a single place, and then re-use them throughout the style sheet, making global changes as easy as changing one line of code. @brand_color: #4D926F; #header { color: @brand_color; } h2...

posted @ Sunday, October 18, 2009 12:54 AM | Feedback (0) |

ASP.NET MVC: Access an action only by ajax

In a standard ‘web 2.0’ (god, I hate that buzzword) web application, you’ll often have ajax calls to your code. I prefer using jQuery, but any method will do. A proper ajax request will set a header value in the HTTP GET request, and ASP.NET is a good boy and catches that. By checking if the IsAjaxRequest() method on the request returns true. This feature can be utilized for something I like to do on my ajax-exclusive controller actions: restrict access in such a way that only ajax requests can call the action. Other actions will get a 404,...

posted @ Monday, October 05, 2009 12:00 PM | Feedback (1) | Filed Under [ c# asp.net mvc ]

ASP.NET MVC: Common viewdata

One issue I’ve heard a few times already when explaining ASP.NET MVC to others is how to deal with common viewdata which should be available to every page. Sure, you can simply add it to the viewdata in each and every controller action you call, but that’s a horrible violation of the DRY (Don’t Repeat Yourself) principle. It’s also very error-prone, because you’re very likely to forget to add it some time or another. A more elegant solution to the problem is to have a base controller class which you will use for all your controllers. This is a...

posted @ Friday, October 02, 2009 1:50 AM | Feedback (1) | Filed Under [ c# asp.net mvc ]