Copied to clipboard

Flag this post as spam?

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


  • Linus Norén 2 posts 32 karma points
    Oct 16, 2014 @ 14:18
    Linus Norén
    0

    System.Web.HttpCompileException when overriding RenderMvcController.Index

    Hi,

    Suddenly I get an System.Web.HttpCompileException when I overide RenderMvcController.Index and tries to return the model. It worked fine yesterday and i haven't done any changes to the code...

    The code looks like this:

    public abstract class KeyCodePageController : Umbraco.Web.Mvc.RenderMvcController
        {
            protected void SetSessionShowHeaderState()
            {
                if (Request["showHeader"== "0")
                {
                    Session["showHeader"= true;
                }
            }
    
            private void SetShowHeaderViewbagState()
            {
                if (Session["showHeader"!= null)
                {
                    ViewBag.ShowHeader = Session["showHeader"];
                }
            }
    
            public override ActionResult Index(RenderModel model)
            {
                SetShowHeaderViewbagState();
                return base.Index(model);
            }
        }

    I get "An exception of type 'System.Web.HttpCompileException' occurred in System.Web.dll"

    In the browser I get this error:
    "system.web.http.apicontroller' is defined in an assembly that is not referenced.  You must add a reference to the assambly System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35."

    But I alredy have a reference to this assambly...

    Please help me, this is driving me crasy.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 16, 2014 @ 18:14
    Dave Woestenborghs
    100

    Probably related to a windows update breaking stuff in the .net framework. I've seen a lot of posts today on twitter concerning the problem.

    Luckily umbraco HQ added a blogpost on how to solve the problem : http://umbraco.com/follow-us/blog-archive/2014/10/16/getting-a-systemwebhttpapicontroller-error

    Dave

  • Linus Norén 2 posts 32 karma points
    Oct 17, 2014 @ 08:52
    Linus Norén
    0

    Thanks Dave! 

    I managed to solve it by reinstalling Visual Studio. But if it's caused by a Windows Security update it's likely to come back. I will add Umbracos fix also. Thanks again!

    /Linus

Please Sign in or register to post replies

Write your reply to:

Draft