Copied to clipboard

Flag this post as spam?

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


  • Steve Morgan 1278 posts 4216 karma points c-trib
    Feb 26, 2019 @ 12:32
    Steve Morgan
    0

    Umbraco Web API - Azure error on Filter Attribute

    Hi,

    I've picked up a solution on behalf of a charity and they've got an issue I just can't seem to get my head around.

    They have a web API controller that has a decoration to use an actionFilter (it just sets a "cart" cookie on most calls).

    public class CartWebApiFilterAttribute : ActionFilterAttribute {
            public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext) {
                base.OnActionExecuted(actionExecutedContext);
    
                var cookies = new List<CookieHeaderValue> {
                    new CookieHeaderValue(Constants.Cookies.CartId, Req.Cart.Id.ToString()) {
                        Expires = DateTimeOffset.UtcNow.AddDays(90),
                        HttpOnly = false,
                        Secure = Workspace.IsLive(),
                        Path = "/"
                    }
                };
    
                actionExecutedContext.Response.Headers.AddCookies(cookies);
            }
        }
    

    We're trying to deploy some updates and take Umbraco from V7.11.1 -> v7.12.4. The server is hosted on Azure - the site starts up great but any calls to the API with this decoration throw this error. I think it's some kind of DLL mismatch but I've tried my hardest to recreate this locally and can't (the API works fine locally on both IIS and IIS Express).

    If I comment out this decoration it works fine.

       <Error>
        <Message>An error has occurred.</Message>
        <ExceptionMessage>
        Method not found: 'System.Net.Http.HttpResponseMessage System.Web.Http.Filters.HttpActionExecutedContext.get_Response()'.
        </ExceptionMessage>
        <ExceptionType>System.MissingMethodException</ExceptionType>
        <StackTrace>
        at HA.Web.CartWebApiFilterAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext) at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()
        </StackTrace>
        </Error>
    

    Anybody seen anything similar? Google searches have not been my friend today.

    Steve

  • Steve Morgan 1278 posts 4216 karma points c-trib
    Feb 26, 2019 @ 17:43
    Steve Morgan
    100

    I think we've worked this out - seems that something in the System.Web.Http or System.Net.Http that was fixed in a Windows Update.

    We were targetting .NET 4.6.2 and it worked locally fine - when we deployed it to the server we got the error above. No about of dll assembly references got us out of the hole.. finding a maintenance window and installing the last couple of months of updates sorted it straight away.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies