Questions tagged [ninject.web.mvc]

extension for ninject providing integration with ASP.NET MVC

Use this tag on questions that describe issues with this specific extension of the framework.

Main features that your question is about:

  • The integration between the Ninject core and ASP.NET MVC
  • Your extended HttpApplication (in Global.asax.cs) with NinjectHttpApplication
  • The activation of your controllers
  • Exposed dependencies and injections of types in
    • constructors
    • properties
    • methods

Github ninject.web.mvc extension

298 questions
2
votes
1 answer

Unit testing models that use validators with injected dependencies

I'm using a custom validator on some of my models in a MVC 5 application. This validator has a dependency on a service that is injected via a property with the Ninject.MVC3 package. (See…
Pete
  • 225
  • 2
  • 6
2
votes
0 answers

Web API File Upload Problems

Using MVC 4 I'm trying to build a Web API controller where you can upload an image. After the upload is complete the controller should save the image in the database. Here is my code: [HttpPost] public void UploadPhoto(int thirdPartyID) { …
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

How can Ninject be configured to always deactivate pooled references?

We're using a library that uses pooled objects (ServiceStack.Redis's PooledRedisClientManager). Objects are created and reused for multiple web requests. However, Dispose should be called after each use to release the object back into the pool. By…
TheCloudlessSky
  • 18,608
  • 15
  • 75
  • 116
2
votes
1 answer

Injecting a complete module in ASP.Net MVC

I am developing a multi-tenant application based on ASP.Net MVC. Depending on the user setup, the site needs to redirect to a separate module/area for that user. Each area has uses some common services, however the site's look and feel and…
2
votes
1 answer

Batch registering all implementations of a generic interface with Ninject

i have the following interfaces injected in Castle Windsor. how do i do the same in Ninject? container.Register( AllTypes.FromAssemblyNamed("Apps.Web") .BasedOn(typeof(ICommandHandler<>)) .WithService.FirstInterface()); i've…
CurlyFro
  • 1,862
  • 4
  • 22
  • 39
2
votes
2 answers

Ninject singleton scope loading

I am very much new to ASP.NET MVC and I need help loading some types in singleton scope using Ninject. --- existing code looks as ---- List types = loading some types into list here. foreach (var type in types.Where(O =>…
mmssaann
  • 1,507
  • 6
  • 27
  • 55
2
votes
2 answers

Ninject.Web.Mvc.FluentValidation and FluentValidation.MVC4

I have tried setting up Ninject.Web.Mvc.FluentValidation in my ASP.NET MVC4 project as shown below: var ninjectValidatorFactory = new NinjectValidatorFactory(kernel); //ModelValidatorProviders.Providers.Add(new…
Pricey
  • 5,799
  • 12
  • 60
  • 84
2
votes
0 answers

Execution order of filters implementing IAuthorizationFilter

I created a filter named PrincipalFilter implementing IAuthorizationFilter interface, to set a custom IPrincipal and IIdentity. This i a global filter. I use dependency injection via Ninject (3.0) so I register my filter as this in a NinjectModule…
gentiane
  • 6,715
  • 3
  • 23
  • 34
2
votes
2 answers

Choose injection constructor based on setting in .config file

I have a MCV3 app that uses Ninject as a DI container. I have one object that has 2 constructors (each with 1 parameter) public MyObject(IDependencyOne dep){} public MyObject(IDependencyTwo dep){} How can I make Ninject choose one of the two…
2
votes
0 answers

What are the requirements for Dependency injection in MVC 4 via Ninject?

I tried to inject dependencies into a controller's constructor, as i have previously. The problem is that i can't seem to get it to work. Is there any new requirement when doing DI with MVC 4 or am i missing some basic requirement ? I'm…
zirus
  • 313
  • 3
  • 13
2
votes
1 answer

How to reinstantiate an MVC3 Controller with a different injection

this is my first question to SO so i'll try not to disgrace myself. What i'm doing right now is injecting two dependency objects to a MVC3 Controller's constructor. But for the sake of the application logic, i need to change those objects with new…
zirus
  • 313
  • 3
  • 13
2
votes
2 answers

Ninject 3.0 is not disposing objects mapped as InRequestScope

I'm trying to use Ninject to manage lifetime on objects. For my IRepository object, I am requiring IDisposable to be implemented, and within the ConcreteRepository, I have implemented IDisposable to kill my NHibernateSession. My issue is that I…
Richard B
  • 1,581
  • 1
  • 15
  • 31
2
votes
3 answers

Ninject MVC 2, EF 4, AutoMapper - ObjectContext has been disposed

Completely revised: Okay, I'm using Ninject with the MVC 2 extension as my DI container, and AutoMapper as my entity <--> view model mapper. I'm getting an 'ObjectContext is disposed' error in my view model -> entity mapping. My code is…
1
vote
3 answers

Mono, ASP.NET MVC 3, Ninject and a default constructor required

I have a working Visual Studio project that I want to run o Mac with Mono and MonoDevelop. The project is an ASP.NET MVC 3 application with Ninject MVC that basically inject on controller some interface implementations. After add all ASP.NET MVC…