ASP.NET MVC 3 Type ‘xxx.xxx’ could not be found.

Here’s a strange little error that I can’t, for some reason, get to the bottom of. My code is reasonably standard and working perfectly on my development machine. When I deploy to an IIS6 box that I’ve set up to work with ASP.NET MVC 3, I keep getting

Type ‘xxx.xxx’ could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly

The error is strange – it only seems to happen when I have slightly more complicated logic in my controller. I had my dbcontext in its own namespace and since this was the namespace that seemed to be referenced in the error, the fix for me was to move my dbcontext out of its own namespace and put it in the Models namespace. Not super neat and tidy, but it works.

An ASP.NET MVC3 implementation of the cancerous Node.js Fibonacci code

I like to tinker with Node.js. Ted Dziuba doesn’t anymore. He thinks node.js is a cancer.
Obviously, a few people disagree – Joshua Kehn and Brian Beck. Ignoring all issues of relevance or flaimbait…and even ignoring all issues of original intent of the article, I was curious to see how C# under ASP.NET MVC3 fared in this little shootout.

I set up a simple MVC application. One controller. It looks like this:

public class HomeController : Controller
    {
        private int Fib(int? n){
            if (n < 2)
            {
                return 1;
            }
            else
            {
                return Fib(n - 2) + Fib(n - 1);
            }
        }

        public string Index(int? n)
        {
            if (string.IsNullOrEmpty(n.ToString()))
            {
                n = 2;
            }
            return Fib(n).ToString();
        }
    }

I ran it on an instance of IIS6.

$ time curl http://localhost/?n=40
default
real    0m0.343s
user    0m0.015s
sys     0m0.015s

Not too bad really. Haskell, however, is super duper fast – as Mathias Biilmann shows.

There’s a little fun for a Tuesday morning.