Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8838381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:58:47+00:00 2026-06-14T09:58:47+00:00

I keep getting this error trying to bind a filter with all actions in

  • 0

I keep getting this error trying to bind a filter with all actions in an a web api controller. I am using Ninject 3.0 and ASP.NET MVC 4.

<Response>
<Message>An error has occurred.</Message>
<ExceptionMessage>Sequence contains no elements</ExceptionMessage>
<ExceptionType>System.InvalidOperationException</ExceptionType>
<StackTrace>
at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source) at Ninject.Web.WebApi.FilterBindingSyntax.FilterFilterBindingBuilder`1.<>c__DisplayClass15`1.<WithConstructorArgumentFromActionAttribute>b__14(IContext ctx, HttpConfiguration controllerContext, HttpActionDescriptor actionDescriptor) in d:\Projects\Ninject.Web.WebApi\src\Ninject.Web.WebApi\FilterBindingSyntax\FilterFilterBindingBuilder.cs:line 385 at Ninject.Web.WebApi.FilterBindingSyntax.FilterFilterBindingBuilder`1.<>c__DisplayClass12.<WithConstructorArgument>b__11(IContext ctx) in d:\Projects\Ninject.Web.WebApi\src\Ninject.Web.WebApi\FilterBindingSyntax\FilterFilterBindingBuilder.cs:line 363 at Ninject.Parameters.Parameter.<>c__DisplayClass6.<.ctor>b__4(IContext ctx, ITarget target) in c:\Projects\Ninject\ninject\src\Ninject\Parameters\Parameter.cs:line 60 at Ninject.Parameters.Parameter.GetValue(IContext context, ITarget target) in c:\Projects\Ninject\ninject\src\Ninject\Parameters\Parameter.cs:line 89 at 

BaseApiController.cs

[ExceptionHandling, ApiValidation, HttpHeader("X-Robots-Tag", "noindex, nofollow")]
    public abstract class BaseApiController : System.Web.Http.ApiController
    {
        protected readonly IApiAuthenticationService ApiAuthenticationService;

        protected BaseApiController(
            IApiAuthenticationService apiAuthenticationService)
        {
            ApiAuthenticationService = apiAuthenticationService;
        }
    }

Global.asax

kernel.BindHttpFilter<HttpHeaderFilter>(System.Web.Http.Filters.FilterScope.Controller)
                       .WhenControllerHas<HttpHeaderAttribute>()
                       .WithConstructorArgumentFromActionAttribute<HttpHeaderAttribute>("name", q => q.Name)
                       .WithConstructorArgumentFromActionAttribute<HttpHeaderAttribute>("value", q => q.Value);

HttpHeaderFilter.cs

using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Controllers;

namespace Tournaments.Models.Mvc.Filters
{
    public class HttpHeaderAttribute : System.Web.Http.Filters.FilterAttribute 
    {
        public string Name { get; set; }
        public string Value { get; set; }

        public HttpHeaderAttribute(string name, string value)
        {
            Name = name;
            Value = value;
        }
    }

    public class HttpHeaderFilter : System.Web.Http.Filters.IActionFilter
    {
        private readonly string _name;
        private readonly string _value;

        public HttpHeaderFilter(string name, string value)
        {
            _name = name;
            _value = value;
        }

        public bool AllowMultiple
        {
            get { return false; }
        }

        public Task<HttpResponseMessage> ExecuteActionFilterAsync(HttpActionContext actionContext, CancellationToken cancellationToken, Func<Task<HttpResponseMessage>> continuation)
        {
            actionContext.Response.Headers.Add(_name, _value);

            return continuation();
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:58:49+00:00Added an answer on June 14, 2026 at 9:58 am

    You attribute is on the Controller. You must use WithConstructorArgumentFromControllerAttribute in this case.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting this error when trying to view my channels controller. uninitialized constant
I keep getting this error when trying to open a connection using entity framework.
So I keep getting this error when trying to compile C++ code using CodeBlocks.
I'm trying to compile a component using ant and keep getting this error message
I'm trying to send SMTP e-mails using PHPMailer, but I keep getting this error
I keep getting this error while trying to modify some tables. Here's my code:
Keep getting this error after inserting a subdatasheet into a query and trying to
Hi I keep getting this error, I'm trying to get tweets from twitter via
I am trying to do a terminal update and I keep getting this error,
I'm trying to connect to SSIS through SSMS but i keep getting this error:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.