Articles : Page 1 of 22

  • DropDownList and SelectListItem Array Item Updates in MVC

    DropDownList and SelectListItem Array Item Updates in MVC

    May 12
    16

    So I ran into an interesting behavior today as I deployed my first MVC 4 app tonight. I have a list form that has a filter drop down that allows selection of categories. This list is static and rarely changes so rather than loading these items from the database each time I load the items once and then cache the actual SelectListItem[] array in a static property. However, when we put the site online tonight we immediately noticed that the drop down list was coming up with pre-set values that...


  • Passing multiple POST parameters to Web API Controller Methods

    Passing multiple POST parameters to Web API Controller Methods

    May 12
    09

    ASP.NET Web API introduces a new API for creating REST APIs and making AJAX callbacks to the server. This new API provides a host of new great functionality that unifies many of the features of many of the various AJAX/REST APIs that Microsoft created before it - ASP.NET AJAX, WCF REST specifically - and combines them into a whole more consistent API. Web API addresses many of the concerns that developers had with these older APIs, namely that it was very difficult to build consistent REST sty...


  • Entity Framework 4.3.1 Migrations and non English locale

    Entity Framework 4.3.1 Migrations and non English locale

    Apr 12
    30

    A few days ago I started migrating a web app I was working on from ASP.NET MVC 3 and EF4 to ASP.NET MVC 4 and EF 4.3.1. All went well, except for some problems with the automatic generation of the DB scheme using EF Code First: it was creating the database, but no tables and not even the __MigrationHistory table added in 4.3; and during the execution of the schema generation an error was raised with a weird datetime conversion error. I tried this both on SQL Express 2005 and SQL Compact and I ...


  • GZip/Deflate Compression in ASP.NET MVC

    GZip/Deflate Compression in ASP.NET MVC

    Apr 12
    28

    A long while back I wrote about GZip compression in ASP.NET. In that article I describe two generic helper methods that I've used in all sorts of ASP.NET application from WebForms apps to HttpModules and HttpHandlers that require gzip or deflate compression. The same static methods also work in ASP.NET MVC. Here are the two routines: /// <summary> /// Determines if GZip is supported /// </summary> /// <returns></returns> public static bool IsGZipSupported() { string AcceptEncoding = HttpCon...


  • ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes

    ASP.NET MVC Postbacks and HtmlHelper Controls ignoring Model Changes

    Apr 12
    20

    So here's a binding behavior in ASP.NET MVC that I didn't really get until today: HtmlHelpers controls (like .TextBoxFor() etc.) don't bind to model values on Postback, but rather get their value directly out of the POST buffer. Effectively it looks like you can't change the display value of a control via model value updates on a Postback operation. To demonstrate here's an example. I have a small section in a document where I display an editable email address: This is what the form displa...


  • Great Free Course on Building ASP.NET MVC Apps With EF Code First, HTML5 and jQuery

    Great Free Course on Building ASP.NET MVC Apps With EF Code First, HTML5 and jQuery

    Apr 12
    20

    Pluralsight has developed a great training course on Building ASP.NET MVC Apps with EF Code First, HTML5 and jQuery. It is presented by the most excellent Dan Wahlin, and is really comprehensive. Details of the course outline can be found here. Free 1-Month Subscription to the Course Pluralsight is offering a special promotion that allows you to get a free 1-month subscription to watch the above course as many time as you want at no cost. There is no obligation to buy anything at the end...


  • April 14th Links: ASP.NET, ASP.NET MVC, ASP.NET Web API and Visual Studio

    April 14th Links: ASP.NET, ASP.NET MVC, ASP.NET Web API and Visual Studio

    Apr 12
    15

    Here is the latest in my link-listing blog series: ASP.NET Easily overlooked features in VS 11 Express for Web: Good post by Scott Hanselman that highlights a bunch of easily overlooked improvements that are coming to VS 11 (and specifically the free express editions) for web development: unit testing, browser chooser/launcher, IIS Express, CSS Color Picker, Image Preview in Solution Explorer and more. Get Started with ASP.NET 4.5 Web Forms: Good 5-part tutorial that walks-through build...


  • Wishful Thinking: Why can't HTML fix Script Attacks at the Source?

    Wishful Thinking: Why can't HTML fix Script Attacks at the Source?

    Apr 12
    15

    The Web can be an evil place, especially if you're a Web Developer blissfully unaware of Cross Site Script Attacks (XSS). Even if you are aware of XSS in all of its insidious forms, it's extremely complex to deal with all the issues if you're taking user input and you're actually allowing users to post raw HTML into an application. I'm dealing with this again today in a Web application where legacy data contains raw HTML that has to be displayed and users ask for the ability to use raw HTML as...


  • Odd MVC 4 Beta Razor Designer Issue

    Odd MVC 4 Beta Razor Designer Issue

    Apr 12
    14

    This post is a small cry for help along with an explanation of a problem that is hard to describe on twitter or even a connect bug and written in hopes somebody has seen this before and any ideas on what might cause this. Lots of helpful people had comments on Twitter for me, but they all assumed that the code doesn't run, which is not the case - it's a designer issue. A few days ago I started getting some odd problems in my MVC 4 designer for an app I've been working on for the past 2 weeks...


  • Rebuilding CoasterBuzz, Part IV: Dependency injection, it's what's for breakfast

    Rebuilding CoasterBuzz, Part IV: Dependency injection, it's what's for breakfast

    Apr 12
    11

    (Repost from my personal blog.) This is another post in a series about rebuilding one of my Web sites, which has been around for 12 years. I hope to relaunch soon. More: Part I: Evolution, and death to WCF Part II: Hot data objects Part III: The architecture using the "Web stack of love" If anything generally good for the craft has come out of the rise of ASP.NET MVC, it's that people are more likely to use dependency injection, and loosely couple the pieces parts of their application...