-1
public static void Register(HttpConfiguration config)
        {
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "v1/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }

I am trying to create API inside a MVC application project, but I am getting below

Error   'System.Net.Http.HttpMessageHandler' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Net.Http, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.   

I tried to google, but not much help I got.

Can any one suggest me a better way.

  • Have you tried this solution - http://stackoverflow.com/questions/9431975/could-not-load-file-or-assembly-system-net-http-version-2-0-0-0-in-mvc4-web-ap – Mitul Nov 02 '15 at 13:14

1 Answers1

0

I got System.Web.Http version 2.0 with .NET Framework 4.0, and it builds perfectly.

But now I have a runtime error

{"Method not found: 'Void Newtonsoft.Json.Serialization.DefaultContractResolver.set_IgnoreSerializableAttribute(Boolean)'."}

Its coming on below line of code

WebApiConfig.Register(GlobalConfiguration.Configuration);
  • This command in Nuget Console solved my problem Install-Package Newtonsoft.Json –IncludePrerelease http://stackoverflow.com/questions/16756336/method-not-found-void-newtonsoft-json-serialization-defaultcontractresolver-set – Vikash Ranjan Jha Nov 03 '15 at 05:51