Questions tagged [ninject.web]

55 questions
2
votes
1 answer

ToConstant while binding in Kernel

We have a code something like below. var xyz = method(); //method() returns an interface say **Interface1** kernel.Bind<**Interface1**>().ToConstant(xyz); I saw on stackoverflow at the below link: Usage of binding to constants and binding to types…
Vicky
  • 624
  • 2
  • 12
  • 35
2
votes
0 answers

Ninject insingletonscope creating multiple instances per request

I'm learning Ninject and doing a trial (thur a web api project). I wrote a controller, which will call a repository and update elements in a data source I have a class which acts as a data source (to kee things simple) public class UserDb { …
Mateen-Hussain
  • 718
  • 1
  • 13
  • 29
2
votes
1 answer

Is it ok to pass Ninject Web.Common UseNinjectMiddleware a lambda which returns a kernel instance?

Why does UseNinjectMiddleware take a lambda instead of a container instance? Is it OK to do this? var container = CreateKernel(); app.UseNinjectMiddleware(() => container); instead of this: app.UseNinjectMiddleware(() => CreateKernel); My…
Jordan Morris
  • 2,101
  • 2
  • 24
  • 41
2
votes
1 answer

I am having issues with Ninject and MVC 5 Web api 2.2

I tried the solution in MVC5, Web API 2 and and Ninject but the package breaks my build(System.Web). I have also tried the "Ninject.MVC3" Package. When i fix it with "Update-Package -reinstall Microsoft.AspNet.WebApi.WebHost", I get the error: An…
2
votes
1 answer

InRequestScope fails to work in context of ExceptionLogger

I have a custom Web API ExceptionLogger which is added in WebApiConfig like so: config.Services.Add(typeof(IExceptionLogger), new CustomExceptionLogger(kernel.Get()); CustomExceptionLogger is: public class CustomExceptionLogger :…
2
votes
3 answers

Ninject.Web.Common No parameterless constructor defined for this object

I used Nuget to install the Ninject.Web.Common reference. I use it with ASP.net Web API (APIController) with no problem, but I hit problem when using the ASP.net MVC 4(Controller). The error: No parameterless constructor defined for this object. …
Alvin
  • 8,219
  • 25
  • 96
  • 177
2
votes
1 answer

Ninject 3.0 (NuGet) with ASP .NET WebForms not calling WebActivator

I created a brand new WebForm site (VS2010) and added Ninject.Web (3.0) from NuGet... It created NinjectWeb and NinjectWebCommon on App_Start... Its compiling fine, but it never exeute the code ... Am I suppose to do something to get WebActivator…
Paul
  • 12,359
  • 20
  • 64
  • 101
1
vote
1 answer

How do I set up an ASP.NET Web Forms application to use Ninject.Web 3.0.0 RC3?

I am trying to set up my ASP.NET Web Forms (Framework 4.0) application to use Ninject.Web. I would like to use RC3 of Ninject 3.0.0, since I ran into issues with databound controls. Through my inspections of Ninject.Web.Common and Ninject.Web, it…
John Bledsoe
  • 17,142
  • 5
  • 42
  • 59
1
vote
1 answer

Dependency Injection with Ninject and Global Filter: IAuthorizationFilter

I use standart NinjectMVC3 Bootstrapper installed in the App_Start folder. My application class looks like: public class MvcApplication : HttpApplication { static void RegisterRoutes(RouteCollection routes) { // ... routes here ... …
Jean Louis
  • 1,485
  • 8
  • 18
  • 33
1
vote
0 answers

Ninject with Owin: InRequestScope doesn't work

I created a project with EF6 + Ninject + Owin. I realized that Ninject InRequestScope doesn't work, infact, in a single Web Api request the constructor of my DBContext derived class fires more than once. The Startup file of my web api project is…
Max Bertoli
  • 614
  • 5
  • 25
1
vote
0 answers

Asp.Net Webforms constructor injection with Ninject

When I try installing Ninject.Web I get: Unable to resolve dependencies. 'Ninject 3.3.4' is not compatible with 'Ninject.Web 3.2.1 constraint: Ninject (>= 3.2.0 && < 3.3.0)' In this SO answer, it is said that we don't have to use Ninject.Web. But…
bati06
  • 307
  • 2
  • 10
1
vote
1 answer

Ninject property injection in MVC3

My code is as fallows below. My issue is the Session is not injected and my session remains Null. What is wrong here? I am using ninject 2.2 public class SessionNinjectModule : NinjectModule { public override void Load() { …
Vartan Arabyan
  • 2,925
  • 7
  • 25
  • 35
1
vote
0 answers

Ninject xml Inject from another class library

I am trying to inject from another class library but it doesn't work, i am getting this error: Couldn't resolve type 'BLL.UserBLL, MyProject.Core' defined in 'to' attribute. XML:
1
vote
0 answers

Using Ninject with static methods

My goal is to use Ninject in my application with static methods. I am aware of the fact that the static methods should not have any dependencies since it is hard from testing point of view. But, in my application I am not in the position to make…
Raghav
  • 8,772
  • 6
  • 82
  • 106
1
vote
1 answer

ASP.NET Web Forms + Ninject + Helper Class with iService - how to make Ninject handle iService?

I have an ASP.NET Web Forms project written in VB.NET running on .NET 4.5.2 I've successfully plugged Ninject into my application however I've hit a snag. I'm using Ninject Property Injection within my web pages (sample below) Partial Class MyPage …