Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Morten Jensen 41 posts 104 karma points
    Nov 26, 2014 @ 10:44
    Morten Jensen
    0

    Custom webAPI routing missing assembly version of System.Net.Http?

    I have tried to make a new custom webAPI route, but are this build error:

    The type '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'.

     

    My custom route i put inside a file called "UmbracoEvents.cs" in the App_Start folder. And the content looks like:

    using System.Web.Http;
    using System.Web.Routing;
    using Umbraco.Core;
    
    
    namespace XXX
    {
        public class UmbracoEvents : IApplicationEventHandler
        {
            public void OnApplicationInitialized(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
            }
    
            public void OnApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
                RouteTable.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
    
            }
    
            public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {
            }
    
        }
    }

    Can anybody spot the hot to fix?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Nov 26, 2014 @ 10:54
    Jan Skovgaard
    100

    Hi Jacob

    Has the correct version been added to the references in your project?

    /Jan

  • Morten Jensen 41 posts 104 karma points
    Nov 26, 2014 @ 11:03
    Morten Jensen
    0

    Of course!!

    When i added to reference manually in VS the project whould build. Thanks

Please Sign in or register to post replies

Write your reply to:

Draft