asp.net
asp.net
I’ve recently had a lot less (pun not intended) time to spend on .less, but I do keep track. Scott Hanselman mentioned the new ASP.NET site went live, and it looks good! What REALLY caught my eye is the section on open source projects it has, under the ‘community’ tab. It has a lot of nice, established projects mentioned, like Nhibernate, Subtext, Spark and a lot of others. What really amazed me is that .less is mentioned! If you scroll down to the Misc section, there it is! Seems like I really have to schedule my work better...
I just ran into a situation which could lead to very annoying latent bugs in your web application. Observe the following code. The view: <form method="post" action="Photo/Save">
<input type="text" name="Photo" />
<input type="text" name="Title" />
</form>
The Controller action:
public ActionResult Save(PhotoDTO photo)
{
// do something with the object
return RedirectToAction("Index");
}
The class:
public class PhotoDTO
{
public string Photo { get; set; }
public string Title { get; set; }
}
At first sight, there’s nothing wrong with this code. You’d say when the form is posted, the PhotoDTO object gets...
I had a short twitter conversation with Aaron Jensen on the decisions we made developing .Less. As I’ve blogged about before, for me personally it was more of a learning project than something with a set goal, at first. That aside, I had one thing in mind: being able to use less during development, without having to worry about it, add a handler and go! Less.Net, v0.1 My first solution was to simply install ruby and wrap the whole system call in a HttpHandler. Very clunky, but it worked! I blogged about this a while ago: Using LessCSS...
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,...
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...