Latest Microsoft Blogs

Browse by Tags

Related Posts

  • Interface Inheritance Esoterica

    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...


  • Html Encoding Nuggets With ASP.NET MVC 2

    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...


  • VS10 Beta 2 From an ASP.NET MVC Perspective

    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...


  • ASP.NET MVC 1.0 Scripts Available on Microsoft CDN

    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...


  • ASP.NET MVC 2 Preview 2

    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...


  • Html Encoding Code Blocks With ASP.NET 4

    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" ) %> <...


  • Fun With Method Missing and C# 4

    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...


  • Rest For ASP.NET MVC SDK and Sample

    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...


  • Default Templated Views

    Note, this blog post is based on Preview 1 of ASP.NET MVC 2 and details are subject to change. I’ll try to get back to normal ASP.NET MVC 1.0 content soon. :) While in a meeting yesterday with “ The Gu ”, the topic of automatic views came up. Imagine if you could simply instantiate a model object within a controller action, return it to the “view”, and have ASP.NET MVC provide simple scaffolded edit and details views for the model automatically. That’s when the light bulb went on for Scott and he briefly mentioned an idea for an approach that would work. I was excited by this idea and decided to prototype it tonight. Before I discuss that approach, let me lead in with a bit of background. One of the cool features of ASP.NET MVC is that any views...


  • Put Your Views (and Pages) On a Diet

    One of the complaints I often here with our our default view engine and Pages is that there’s all this extra cruft in there with the whole page directive and stuff. But it turns out that you can get rid of a lot of it. Credit goes to David Ebbo , the oracle of all hidden gems within the inner workings of ASP.NET, for pointing me in the right direction on this. First, let me show you what the before and after of our default Index view ( reformatted to fit the format for this blog ). Before <%@ Page Language ="C#" MasterPageFile ="~/Views/Shared/Site.Master" Inherits ="System.Web.Mvc.ViewPage" %> < asp:Content ID ="indexTitle" ContentPlaceHolderID ="TitleContent" runat ="server"...


Page 1 of 9 (89 items) 1 2 3 4 5 Next > ... Last »
Microsoft Communities