After namespace change “multiple types were found that match the controller named ‘X'”

I started work on a new MVC 5 project today and after working on it for a short while I decided I wanted to change the name of the web project to [ProjectName].WebUI from just [ProjectName].  So, I renamed the project, updated the project namespace and updated all my files to use the new namespace so my solution was now made up of [ProjectName].sln, [ProjectName].WebUI and [ProjectName].WebUI.Tests.  All good I thought, but then I went to debug it and got this message:

Multiple types were found that match the controller named ‘Home’. This can happen if the route that services this request (‘{controller}/{action}/{id}’) does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the ‘MapRoute’ method that takes a ‘namespaces’ parameter.

Continue reading

How to Install a NuGet package Without an Internet Connection

If, like me, you are currently working on a development PC that doesn’t have access to the internet it can be a pain trying to install and maintain third party packages.  I’m a huge fan of NuGet and I thought that as I didn’t have an internet connected machine I wouldn’t be able to connect to it and download my favourite packages via Visual Studio’s Package Manager.  I was wrong though as it’s possible to use Visual Studio’s Package Manager to install NuGet packages even when you don’t have an internet enabled development machine Continue reading

.Net Extension Methods

Extension Methods – What are they?

They are methods written by you which allow you to extend classes that you cannot modify directly.  These might be classes you’re using from a third party DLL, or maybe you work in an organisation where your business objects are untouchable by a lowly developer such as yourself (and me), or maybe you just want to add some extra functionality to the String class.  If any of these situations ring true then extension methods are something you should know about. Continue reading

Managing Static Data in a SQL Server Visual Studio Project

I’m a fan of the SQL Server project type that ships with Visual Studio having used it over the years with a number of projects.  I’ve been away from it for a couple of years though having been working with a company that preferred Redgate’s SQL Source Control offering, so coming back to SQL Server projects again my memory’s been a bit hazy and I’ve struggled how to remember to do some things.

One of these things was how to manage static data Continue reading

How to Unit Test a Private Method with MSTest

Okay so I’m not going to get into the debate about whether or not private methods should be unit tested as that’s not the purpose of this post (for what it’s worth I think they shouldn’t be tested), but as MSTest provides functionality to test private methods it makes sense that I should know how to set a test up for the occasion where a client wants me to write unit tests for private methods. Continue reading

ZeroClipboard Multiple Times on a Single Page

Took my first look at ZeroClipboard the other week and I have to say I like it a lot.

What is ZeroClipboard?

So, what is it?  It’s a small (important), free (very important) and cross-browser (very, very important) library which uses an invisible Adobe Flash movie and JavaScript interface that lets you easily copy text from your website to the clipboard. Continue reading

Infinite Scroll with a Repeater

One of the requirements for a project I have been working on lately is that paging of data is not allowed.  The solution so far had been just to output all the records to a GridView control which was fine until the data behind the application started to grow.  Once where only 50, 100, 200 records were being written out we are now getting 1000+ which, as you might expect, was not ideal for page rendering.

So I’ve looked at introducing paging back into the project but in an infinite scrolling capacity. Continue reading

C# When to use Ref vs Out

Interesting question asked of me today by another developer who was fairly new to C# and that was

What’s the difference between ref and out?

Well it’s a good question and it took me a minute or two to remember but once I had remembered (and supplemented my knowledge thanks to a bit of Googling) I thought I’d add the answer here. Continue reading