-
|
One of the upcoming new features being added to ASP.NET MVC 2 Beta is a little helper method called Html.RenderAction and its counterpart, Html.Action . This has been a part of our ASP.NET MVC Futures library for a while, but is now being added to the core product. Both of these methods allow you to call into an action method from a view and output the results of the action in place within the view. The difference between the two is that Html.RenderAction will render the result directly to the Response (which is more efficient if the action returns a large amount of HTML) whereas Html.Action returns a string with the result. For the sake of brevity, I’ll use the term RenderAction to refer to both of these methods. Here’s a quick look at how...
|
-
|
Today at PDC09 (the keynote was streaming live ), Bob Muglia announced the release of ASP.NET MVC 2 Beta . Feel free to download it right away! While you do that I want to present this public service message. The Beta release includes tooling for Visual Studio 2008 SP1. We did not ship updated tooling for Visual Studio 2010 because ASP.NET MVC 2 is now included as a part of VS10, which is on its own schedule. Unfortunately, because Visual Studio 2010 Beta 2 and ASP.NET MVC 2 Beta share components which are currently not in sync, running ASP.NET MVC 2 Beta on VS10 Beta 2 is not supported . Here are some highlights of what’s new in ASP.NET MVC 2. RenderAction (and Action) AsyncController Expression Based Helpers (TextBoxFor, TextAreaFor, etc....
|
-
|
I learned something new yesterday about interface inheritance in .NET as compared to implementation inheritance. To illustrate this difference, here’s a simple demonstration. I’ll start with two concrete classes, one which inherits from the other. Each class defines a property. In this case, we’re dealing with implementation inheritance . public class Person { public string Name { get; set; } } public class SuperHero : Person { public string Alias { get; set; } } We can now use two different techniques to print out the properties of the SuperHero type: type descriptors and reflection. Here’s a little console app that does this. Note the code I’m showing below doesn’t include a few Console.WriteLine calls that I have in the actual app. static...
|
-
|
In a recent blog post, I introduced ASP.NET 4’s new HTML Encoding code block syntax as well as the corresponding IHtmlString interface and HtmlString class. I also mentioned that ASP.NET MVC 2 would support this new syntax when running on ASP.NET 4 . In fact, you can try it out now by downloading and installing Visual Studio 2010 Beta 2. I’ve also mentioned in the past that we are not conditionally compiling ASP.NET MVC 2 for each platform. Instead, we’re building System.Web.Mvc.dll against ASP.NET 3.5 SP1 and simply including that one in VS08 and VS10. Thus when you’re running ASP.NET MVC 2 on ASP.NET 4, it’s the same byte for byte assembly as the same one you would run on ASP.NET 3.5 SP1. This fact ought to raise a question in your mind. If...
|
-
|
You probably don’t need me to tell you that Visual Studio 2010 Beta 2 has been released as it’s been blogged to death all over the place. Definitely check out the many blog posts out there if you want more details on what’s included. This post will focus more on what Visual Studio 2010 means to ASP.NET MVC and vice versa. In the box baby! Well one of the first things you’ll notice is that ASP.NET MVC 2 Preview 2 is included in VS10 Beta 2. When you select the File | New menu option, you’ll be greeted with an ASP.NET MVC 2 project template option under the Web node. Note that when you create your ASP.NET MVC 2 project with Visual Studio 2010, you can choose whether you wish to target ASP.NET 3.5 or ASP.NET 4. If you choose to target ASP.NET 4...
|
-
|
A little while ago, Scott Guthrie announced the launch of the Microsoft Ajax CDN . In his post he talked about how ASP.NET 4 will have support for the CDN as well as the list of scripts that are included. The good news today is due to the hard work of Stephen Walther and the ASP.NET Ajax team , they’ve added a couple of new scripts to the CDN which are near and dear to my heart, the ASP.NET MVC 1.0 scripts. The following code snippet shows how you can start using them today. < script src ="http://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.js" type ="text/javascript" ></ script > < script src ="http://ajax.microsoft.com/ajax/mvc/MicrosoftMvcAjax.js" type ="text/javascript" ></ script...
|
-
|
Today we just released ASP.NET MVC 2 Preview 2 for Visual Studio 2008 SP1 (and ASP.NET 3.5 SP1), which builds on top of the work we did in Preview 1 released two months ago . Download Page Release Notes Roadmap Some of the cool new features we’ve added to Preview 2 include: Client-Side Validation – ASP.NET MVC 2 includes the jQuery validation library to provide client-side validation based on the model’s validation metadata. It is possible to hook in alternative client-side validation libraries by writing an adapter which adapts the client library to the JSON metadata in a manner similar to the xVal validation framework . Areas – Preview 2 includes in-the-box support for single project areas for developers who wish to organize their application...
|
-
|
One great new feature being introduced in ASP.NET 4 is a new code block ( often called a Code Nugget by members of the Visual Web Developer team ) syntax which provides a convenient means to HTML encode output in an ASPX page or view. <% : CodeExpression %> I often tell people it’s <%= but with the = seen from the front. Let’s look at an example of how this might be used in an ASP.NET MVC view. Suppose you have a form which allows the user to submit their first and last name. After submitting the form, the same view is used to display the submitted values. First Name: <% : Model.FirstName %> Last Name: <% : Model.FirstName %> < form method ="post" > <% : Html.TextBox( "FirstName" ) %> <...
|
-
|
Warning : What I’m about to show you is quite possibly an abuse of the C# language. Then again, maybe it’s not. ;) You’ve been warned. Ruby has a neat feature that allows you to hook into method calls for which the method is not defined. In such cases, Ruby will call a method on your class named method_missing . I showed an example of this using IronRuby a while back when I wrote about monkey patching CLR objects . Typically, this sort of wild chicanery is safely contained within the world of those wild and crazy dynamic language aficionados, far away from the peaceful waters of those who prefer statically typed languages. Until now suckas! ( cue heart pounding rock music with a fast beat ) C# 4 introduces the new dynamic keyword which adds...
|
-
|
When building a web application, it’s a common desire to want to expose a simple Web API along with the HTML user interface to enable various mash-up scenarios or to simply make accessing structured data easy from the same application. A common question that comes up is when to use ASP.NET MVC to build out REST-ful services and when to use WCF? I’ve answered the question before, but not as well as Ayende does (when discussing a different topic). This is what I tried to express. In many cases, the application itself is the only reason for development [of the service] “ [of the service] ” added by me. In other words, when the only reason for the service’s existence is to service the one application you’re currently building, it may make more sense...
|