R# Asp.Net Mvc Inherits Errors

Was fighting an annoying aspx / R# error for a couple of hours this morning. I’ve reported this as a bug to R#:

The basic problem: R# doesn’t highlight correctly if your Inherits directive is not fully qualified. Even if it is in an @Import directive or in your Web.config. The solution is to always fully qualify your Inherits page directive. Or for R# to recommend importing it or fully qualifying it or actually reading the web.config correctly. Go vote my issue up. :)

Posted in Uncategorized | Leave a comment

Agile Open Northwest 09

I’ll be spending the next two days at a Agile Open Northwest. If you’re at the conference, come find me. :)

Otherwise I’ll be blogging about anything I find especially insightful.

Posted in Uncategorized | Leave a comment

Primary Keys

I’ve spent most of the past couple of days mapping a legacy database with NHibernate. Here’s how the design of this database probably went down:

Pointy Haired Boss: We’ve decided to cut costs by paying you per primary key instead of per hour.
DBA: Works for me.

Seriously. We have tables here with two varchars, one decimal, and one int ALL mapped to a primary key. So glad that I have NH to help me out here.

Posted in Uncategorized | Leave a comment

MVC RC1 Bug – And asp.net forums whining

Simple enough, it looks like some standards nazi went through and renamed the Login to Logon in several places for RC1. Unfortunately it did not get renamed in the Web.config for the redirect on failed login url.

    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login"/>

Where it needs to be:

    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn"/>

But when I went to the asp.net forums to report this bug, I did the conscientious thing and tried to determine if it had been reported already. Searching for “RC1 logon login” yielded too many results. So I’ll wade through the tree view to only check the asp.net mvc forum. (2004 called, wants it back.) I then realized it was sorting by some kind of relavance instead of date. Where’s the date sort? Lets try going back to the “more search options” Ohh, thanks for clearing my existing search. Perhaps if I hit “back” instead? Still no luck. Ohh wait, there’s a big notice at the top of the search page:

Search will be undergoing maintenance to improve results on Tuesday, January 6, 2009 from 7pm – 10pm Eastern Time, United States.

Ohh. So this is the IMPROVED version? Sigh. I’ll post it here instead.

Posted in Uncategorized | Leave a comment


As I’m sure you noticed, MVC RC1 is out now. In reading through the release notes I found this:

“The overloads for DropDownList and ListBox helper methods were reworked to fix various usability problems that were reported by customers.”

Thanks for listening!

Posted in ASP.Net, c# | Leave a comment

Stock Photos FTW

Sometimes using a stock photo can help sell your product. Perhaps this one is trying to convince the buyer what not to do. Or something.


Posted in Uncategorized | Leave a comment

GAC Conflicts with ASP MVC

By some strange combination of beta and pre-release candidate installs I managed to create some serious conflicts with ASP.NET MVC. Thereby producing this wonderful little error:

Compiler Error Message: CS0433: The type 'System.Web.Mvc.FormMethod' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Mvc\\System.Web.Mvc.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\06c0b3cf\32bec25d\assembly\dl3\71bfb65b\e11bf5c5_9e55c901\System.Web.Mvc.DLL'

I am using my own build of the source from codeplex so that I can debug through it to improve my knowledge of the codebase. From research online it looks like the assembly version between the latest pre-release and the beta weren’t incremented, or the web-runner tries to look in the GAC before the /bin, or the evil garden gnomes are at it again, or Microsoft wants to punish me for building THEIR dll files.

To solve this problem, i opened up the AssemblyInfo.cs files of the Mvc project and upped the AssemblyVersion to Then hacked my web config to use that version. As I’m running in debug mode, and can’t sign the assembly I also had to remove the PublicKeyToken from the reference.

<add assembly="System.Web.Mvc, Version=, Culture=neutral"/>

And suddenly we’re back in business.

Posted in ASP.Net, c# | 1 Comment

Round datetime to nearest 5 minutes

This took me forever to find online, so I’m posting it here for the next helpless soul. If you need to round datetimes coming out of sql to the nearest 5 minutes, here you go.

dateadd(mi,(datepart(mi,dateadd(mi,1,DateTimeColumn))/5)*5,dateadd(hh,datediff(hh,0,dateadd(mi,1, DateTimeColumn)),0))

Posted in Uncategorized | Leave a comment

Personal Blog

If you want to hear random drivel about my life, I’ve started a personal blog over at willshaver.com. I will continue to use this one for software related posts.

Posted in Uncategorized | Leave a comment

Headaches with ASP.MVC UI Helpers

I’ve been beating my head against the UI helpers a lot lately and wanted to share a frustration point. Say I want to do something using the DropDownList, so you map a property on your page that returns a Select List:

<%= Html.DropDownList("db", SelectList)%>

        public static SelectList SelectList
                List<ListItem> items = new List<ListItem>
                                               new ListItem {Selected = true, Text = "All", Value = ""},
                                            new ListItem {Text = "Apples", Value = "Ap"},
                                            new ListItem {Text = "Bananas", Value = "Bn"},
                                            new ListItem {Text = "Oranges", Value = "Or"}
                return new SelectList(items);

Seems simple enough right? I’m giving the select list a list of ListItem. I’m using YOUR api. I don’t expect that THIS is what I get back:

Looks like you’re assuming that I won’t use your list of items:

        [SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate",
            Justification = "Operation performs conversions and returns a unique instance on each call.")]
        public virtual IList<ListItem> GetListItems() {
            return (!String.IsNullOrEmpty(DataValueField)) ?
                GetListItemsWithValueField() :

Perhaps a check to see if the items in the enumerable ARE already LISTITEM would be appropriate?

For the record, changing it to this makes the code work:

return new SelectList(items, "Value", "Text", items[0]);

But what happened to convention over configuration?

Edit: ok, the “correct” way I posted wasn’t actually correct. You can’t put the “Selected” item in the selectedValue field, you have to put the value there, in this case “Bn” or “Ap” etc. Heaven forbit putting the actual selected item as the parameter. Or pulling the selected item automatically from request values.

Posted in Uncategorized | 1 Comment