0
votes

So I installed Umbraco CMS in an empty MVC 5 application, got it to work, then when I tried to add a MVC 5 controller I realized Umbraco only supports < MVC 4, so the controller replaced the reference and stopped working.

Started a new MVC 4 project and installed Umbraco CMS, but then when I try to build I get the following error:

The type or namespace name 'HttpConfiguration' could not be found (are you missing a using directive or an assembly reference?) in WebApiConfig.cs file.

I have the reference System.Web.Http added correctly (v4.0, runtime version 4.0.30319) but in the WebApiConfig.cs file it somehow finds the class yet still think it's wrong:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Http;

namespace MyProj
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }
}

Any idea what could be wrong?

Thanks in advance

deSex

EDIT:

I updated my NuGet packages and now it works. I think it was the System.Web.Mvc.dll that needed an update, although it changed the Web.config to point to the wrong version. After altering that, it worked.

1

1 Answers

0
votes

Sometimes its best just to remove System.Web.Http as a reference then add it again as a quick fix then do clean and rebuild.

Also you could try going into the properties of System.Web.Http and changing specific version to false.

Failing that I would look into the web.config binding redirects.

Hope that helps.