Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Dev Blog - Johan Danforth

I'm Johan Danforth and this is my dev blog - a mix of .NET, ASP.NET, Rest, Azure and some other random coding stuff.

  • www.NServiceBus.com is Online

    Udi Dahan just blogged about the new site for nServiceBus:

    www.NServiceBus.com is online.

    It’s not “done” yet, but I’m pretty sure it’s past time that nServiceBus had its own site separate from this blog. I’m still working out the DNS and other domain forwarding and hosting stuff, but we’re live.

    There is some information on the “overview” page about one-way messaging, store-and-forard, and why those patterns were chosen for nServiceBus.

    Check it out.

  • [Vista] SP1 Available for MSDN Subscribers

    Lots of people have now blogged about the availability of Vista SP1 on MSDN Subscription, but what is new and when will it be available for the public? I Googled around a bit...

    Mike Nash on the Windows Product Management group blogs on the Windows Vista Blog:

    With Service Pack 1, we have made great progress in performance, reliability and compatibility.

    ...

    ...with SP1, copying or moving files around your PC, your home network or your corporate network should now be much faster.

    ...

    In addition, on many kinds of hardware, resuming a Windows Vista-based PC from sleep is faster on Service Pack 1.

    ...

    we will begin making SP1 available through Windows Update in mid-March

    Mike also writes about better support for hardware, which is about time ;) There's a pretty good page on Technet which describes the Notable Changes in Windows Vista Service Pack 1.

  • Differentiated UX

    I cannot help to smile when reading Udi Dahans view on "Differentiated UX":

    As if there wasn’t enough stuff for developers to deal with.

    After the grand release of WPF, and the industry’s collective shrug and back to business, Microsoft stirs the pot again.

    Yes, a compelling user interface may sell and 3D-views may help get a better understanding or a new insight of complex data, but showing the right data, at the right time is more important. Having said that, some of the new features of WPF and Silverligth migth actually help you with that, but application designers/architects should know what to prioritize.

    I've always been interested in trying out new stuff, but .NET developers are getting swamped with too many new things from Microsoft now. Being a generalist gets harder and harder - I've no idea when I will find time to sit down and have a look at all new stuff. I used to find time to install and test new frameworks and tools, but it's mostly down to reading blogs and looking at webcasts for me nowadays.

  • [SQL] Tools I Can't Live Without Right Now

    I've been doing loads of SQL crunching lately, staging, versioning, and preparing for a pretty large migration job later this year which involves a great deal of schema and data changes in SQL Server 2005.

    A tool which has been saving me a great deal of time is Red Gate's SQL Compare. As the names says, it's able to compare everything you're interested between two databases in when it comes to SPs, tables, functions, roles and so on. You can also generate SQL scripts which wil handle the migration from one version of the database to the other without (if possible) corrupting the data. The tool is dead easy to get into I think - no need to read any manuals or anything, just new, select db1, db2 and compare. Check, uncheck and migrate.

    Red Gate also has a SQL Data Compare tool which compares data in two identical databases and helps you move data between them.

    If you just want to create a bunch of "INSERT INTO ..." SQL statements from existing tables, perhaps you should look at the stored proc Narayana Vyas Kondreddi has made available from his code library:

    This procedure generates INSERT statements using existing data from the given tables and views. Later, you can use these INSERT statements to generate the data. It's very useful when you have to ship or package a database application. This procedure also comes in handy when you have to send sample data to your vendor or technical support provider for troubleshooting purposes.

    To show you how simple this one is, the easies way to run it is just:

    EXEC sp_generate_inserts 'titles'

    and out comes a bunch of INSERT statements which you can copy/paste into your batch files. I love small tools like that.

  • SourceSafe CTP for VS2008

    Richard Berg (BUGBUG) from the Developer & lifecycle tools at Microsoft says:

    If you plan to use VS 2008 with SourceSafe, make sure to pick up the Update CTP too.  Without it, some features like "Open from Source Control" will not work at all.

    Bharry wrote:

    We are working on an update for Visual SourceSafe 2005 to make it work with VS 2008.  We had originally planned to have it available at the same time as VS 2008 downloads went live but we hit a last minute bug that is taking a little time to work out.  Our current expectation is that it will be available in mid December. 

    Not that I'm using SourceSafe any longer (if I can avoid it...) but I'm sure lots of people have already installed VS2008 and wondered about VSS support.

  • ASP.NET MVC Framework (Part 1) - ScottGu's Blog

    I think Scott Guthrie himself just did a better job than me to describe that basics of the ASP.NET MVC Framework on his blog :)

    Since then I've been answering a lot of questions from people eager to learn more about it.  Given the level of interest I thought it might make sense to put together a few blog posts that describe how to use it in more detail.  This first post is one of several I'll be doing in the weeks ahead.

    ASP.NET MVC Framework (Part 1) - ScottGu's Blog

    Go read it already, it got loads of nice pictures to help get an understanding of it all, including the folder structure which is used as a convention. Somewhat influenced by Ruby on Rails I would say ;)

    Considering what I've seen so far of MCV Framework, together with LINQ for SQL and the test framework it reminds me a lot of RoR, but perhaps not as much "convention over configuration" though.

  • A Quick Look at the Basics of ASP.NET MVC

    I had a look at the demo code that Scott Hanselman made available :) So how does it look when using the ASP.NET MVC framework? Of course, since this is MVC, you got the "model", "view" and "controller" parts, but when listening to Scott Guthrie, it seems to be more about "router", "view" and "controller" and he's repeating the fact that this framework is very extensible - you can go with the out of the box stuff, or hack up your own.

    The aim seems to be to have a very clean separation of these parts, so you can swap out the view enging if you want to, and it should also be easier to test your application for those of you who are into TDD and unit testing in general. Therefore there is also support for dependency injection.

    The old ASP.NET stuff that we know and love is still there - code behind, controls, authentication and roles and such. The default view engine is ASPX, but postbacks are not supported, so obviously the way you use some of the ASP.NET controls will change.

    One big difference with URLs in standard ASP.NET vs. MVC is that they do not point directly at the page (like default.aspx) to be rendered, but at a "Controller" which handles the business logic, processes the data and then renders it to a view (which could be the default.aspx page for example). The trick is to map the URL to a controller, and this part seems to be very "configurable". The REST-style of URLs is used alot in the demos, so for example:

        /products/
        /products/42
        /products/delete/42

    Thanks to a URL routing engine, the right method, in a specific controller will be targeted for each URL above, with the right parameters supplied, like:

        /<controller>/<action>/<parameter>

    So, stealing a sample from Guthrie's demo, to set up a Route for URLs like these:

       /Home
       /Home/Index
       /Home/PrintNumber/45

    you would do something like this:

       Routes.Add(new Route("Home", "/Home/[action]/[id]", typeof(HomeController)));

    For the route above, which could be initiated in Global.asax, all URLs that begin with "/Home" will be handled by HomeController which will have methods to handle the "Index" and "PrintNumber" actions. There are several ways to set up default controllers and actions, but I'm now going into that here.

    Note: this was how it was demoed in the ALT.Net video by Guthrie, but it seems that have changed in released demo code. I'll look closer at it later.

    The HomeController class could look something like this:

      public class HomeController : Controller
      {
        [ControllerAction]
        Index()
        {
          //add code here for the default "view"...
        }

        [ControllerAction]
        PrintNumber(int number)
        {
          //add code here to print out a number...
        }
      }

    The [ControllerAction] attribute was added for security reasons so that anyone just cannot type in any action in the URL and run methods in the controller that wasn't supposed to be run. If you don't like that attribute, it's a policy that can be overridden.

    To make the Controller Action output something to the browser, you could use the Response object like this:

      [ControllerAction]
      Index()
      {
        Response.Write("<b>You're at the Index Page (action)!</b>");
      }

    or you could (will in most cases) point at a view (like an ASPX page) to handle the rendering like this:

      RenderView("Home");

    which would render a "Home.aspx" view page you've created.

    If you want to pass parameters to the view, you could use the ViewData collection and do:

        [ControllerAction]
        PrintNumber(int number)
        {
          ViewData("number") = number;
          RenderView("ShowNumber");
        }

    and the page "ShowNumber.aspx" would have some HTML in it to handle the printing of that number, like so:

      <body>
          <div>
              The number waws: <%= ViewData["number"] %>
          </div>
      </body>

    There are ways to pass data to the view in a strongly typed way, by letting the Controller class inherit from a Controller<T> where T is a simple class used to hold properties you'd like to pass to the view. Then ViewData would be of type T. Normally, the code behind for the ASPX page used for the view inherits from the class ViewPage (which is a difference from ordinary ASP.NET pages), but when using Controller<T>, the ASPX-page should inherit from ViewPage<T> to get strong typing of the ViewData class too. Nice!

    I guess that's enough to just let you get a glimpse of how this stuff will work. I'm sure things will change over time, but I believe this is the general idea.