Articles : Page 1 of 2

  • Two bugs in ASP.NET MVC 3 and a workaround for both

    Two bugs in ASP.NET MVC 3 and a workaround for both

    Jun 11
    14

    So I spent an hour today arsing about with a couple of ASP.NET MVC 3 bugs. One was a Routing issue that caused it to act differently to MVC 2. The second I found was a FormsAuthentication issue that insisting on sending me to /Account/Login. Amazing how this crept in really given that it was community tested to death with such a massive ASP.NET MVC following so it is a wonder they weren't weeded out and fixed before RTM. Oh well, don't pretend you don't like a challenge. Routing doesn't work t...


  • Adding MVC dependencies to a project for deployment

    Adding MVC dependencies to a project for deployment

    Jun 11
    13

    Deployment of new web applications has been a bit annoying since the birth of ASP.NET MVC. Production servers with .NET 4 or 3.5 installed will still be missing key assemblies such as System.Web.Mvc.dll. This will cause errors such as "Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies" and "Could not load file or assembly 'System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf38...


  • Routing Regression With Two Consecutive Optional Url Parameters

    Routing Regression With Two Consecutive Optional Url Parameters

    Feb 11
    20

    It pains me to say it, but ASP.NET MVC 3 introduces an ugly regression in routing from ASP.NET MVC 2. The good news is that there’s an easy workaround. The bug manifests when you have a route with two consecutive optional URL parameters and you attempt to use the route to generate an URL. The incoming request matching behavior is unchanged and continues to work fine. For example, suppose you have the following route defined: routes.MapRoute("by-day", "archive/{month}/{day}", new { contro...


  • MvcSiteMapProvider 3.0.0 released

    MvcSiteMapProvider 3.0.0 released

    Feb 11
    04

    Just a quick note to tell that MvcSiteMapProvider 3.0.0 has been released and is available on CodePlex and NuGet. This version is targeted at ASP.NET MVC 3. If you are still using ASP.NET MVC 2, no worries: version 2.3.1 contains the exact same functionality but is targeted at ASP.NET MVC 2. The changelog: Additional UpdatePriority options for generating XML sitemaps Allow to specify target on SiteMapTitleAttribute One action with multiple routes and breadcrumbs Medium Trust optimizatio...


  • MVC 3 AdditionalMetadata Attribute with ViewBag to Render Dynamic UI

    MVC 3 AdditionalMetadata Attribute with ViewBag to Render Dynamic UI

    Jan 11
    31

    A few months ago I blogged about using Model metadata to render a dynamic UI in MVC 2. The scenario in the post was that we might have a view model where the questions are conditionally displayed and therefore a dynamic UI is needed. To recap the previous post, the solution was to use a custom attribute called [QuestionId] in conjunction with an “ApplicableQuestions” collection to identify whether each question should be displayed. This allowed me to have a view model that looked like this: ...


  • ASP.NET MVC 3 and NuGet 1.0 Released (Including Source Code!)

    ASP.NET MVC 3 and NuGet 1.0 Released (Including Source Code!)

    Jan 11
    13

    The changing of the year is a time of celebration as people reflect thoughtfully on the past year and grow excited with anticipation for what’s to come in the year ahead. Today, there’s one less thing to anticipate as we announce the final release of ASP.NET MVC 3 and NuGet 1.0! Oh yeah, this never gets old. Install it via Web Platform Installer or download the installer directly to run it yourself. Here are a few helpful resources for learning more about this release: What’s New in...


  • Class-Level Model Validation with EF Code First and ASP.NET MVC 3

    Class-Level Model Validation with EF Code First and ASP.NET MVC 3

    Dec 10
    10

    Earlier this week the data team released the CTP5 build of the new Entity Framework Code-First library. In my blog post a few days ago I talked about a few of the improvements introduced with the new CTP5 build. Automatic support for enforcing DataAnnotation validation attributes on models was one of the improvements I discussed. It provides a pretty easy way to enable property-level validation logic within your model layer. You can apply validation attributes like [Required], [Range], a...


  • A Better ASP.NET MVC Mobile Device Capabilities ViewEngine

    A Better ASP.NET MVC Mobile Device Capabilities ViewEngine

    Nov 10
    17

    In March of 2009 I spoke at Mix 09, Microsoft's Web Conference and presented a number of ASP.NET MVC features. I extended the NerdDinner Sample with a naive implementation of what I called a MobileCapableWebFormViewEngine. Here's the basic implementation. Don't use this, it's broken. public class MobileCapableWebFormViewEngine : WebFormViewEngine{ public override ViewEngineResult FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) { ViewEngineRes...


  • August 29th Links: .NET, ASP.NET, IIS Express, Silverlight, Windows Phone 7

    August 29th Links: .NET, ASP.NET, IIS Express, Silverlight, Windows Phone 7

    Aug 10
    30

    Here is the latest in my link-listing series. Also check out my VS 2010 and .NET 4 series and ASP.NET MVC 2 series for other on-going blog series I’m working on. [In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu] .NET/WPF/EF 5 Little C#/.NET Wonders that Make Code Better: Nice blog post from James that highlights 5 nice language/framework tips you can take advantage of within your apps. I’m betting a lot of peopl...


  • London “Guathon” Event with Me on August 13th

    London “Guathon” Event with Me on August 13th

    Aug 10
    02

    The (awesome) UK developer community is holding an all day event with me in London on August 13th. The event is free to attend, and the venue will be in Central London (at the ODEON Covent Garden). The website for the event is here. Content The event will be a packed day of presentations covering VS 2010, ASP.NET 4, ASP.NET MVC, and Silverlight for Windows Phone 7. Below is the list of talks: VS 2010 and ASP.NET 4 (90 minutes) A demo heavy talk that covers some of the new features and c...