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

Why does Ninject Mvc NinjectHttpApplication not use IControllerFactory for CreateControllerFactory()

I was looking over the Ninject MVC source code, and the method that generates a controller factory for overwriting the default is hardcoded to only return a NinjectControllerFactory, however as its set as virtual it would make more sense (in my…
Grofit
  • 17,693
  • 24
  • 96
  • 176
2
votes
2 answers

Using Ninject with custom WebViewPage type

I am using ASP.NET MVC 3 + Ninject in my application which works great with my controllers. I also have a custom base page class that inherits from WebViewPage and I have setup an interface that I'd like to be injected in that custom base page…
Doug
  • 14,387
  • 17
  • 74
  • 104
2
votes
1 answer

Using Ninject in a Custom Authorize Attributes

I'm using Ninject to Inject my dependency in my Custom Authorize Attribute: public class ValidatePermissionAttribute : AuthorizeAttribute, IAuthorizationFilter { [Inject] public IUsuarioRepository UsuarioRepository { get; set; } } My…
Acaz Souza
  • 8,311
  • 11
  • 54
  • 97
2
votes
1 answer

System.IO.FileLoadException: 'Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)'

I am getting this error (System.IO.FileLoadException: 'Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)') when running my C# MVC solution targeting .Net Framework 4.7 in Visual…
2
votes
1 answer

ASP.NET MVC and Ninject 2.0 Binding Question

I have a Class called MyMailSender that binds to the asp.net controller called EmailController. E.g. public EmailController(IMailSender sender) { //MyMailSender this.sender = sender; } This MyMailSender class also is…
Nate
  • 2,044
  • 4
  • 23
  • 47
2
votes
2 answers

ASP.NET MultiLayer App Migration To ASP.NET Core

I migrate my ASP.NET multi layer project to ASP.NET Core. I was using Ninject for DI in my old project and i could call it as follow in my BLL. public void IamMethodInBll() { ... //i could call ninject like this. var prodCalcManager =…
Yargicx
  • 1,704
  • 3
  • 16
  • 36
2
votes
3 answers

NInject and MVC 3 - Should I use DependencyResolver instead of [Inject] attribute?

Recently I moved to MVC 3 and Ninject 2. In most of the code, I use constructor injection, but there are some places, where I had to use Inject attribute. Ninject 2 registers its own IDepencyResolver interface. I don't like DependencyResolver class…
LukLed
  • 31,452
  • 17
  • 82
  • 107
2
votes
1 answer

Dependency Injection fails with MVC5 and Ninject

I'm trying to inject a couple of classes in a controller, but I'm failing. This is what I've done: Added Ninject.Web.WebApi.WebHost and WebActivatorEx NuGet packages Created the following class under App_Start: NinjectWebCommon.cs using…
Mark
  • 4,338
  • 7
  • 58
  • 120
2
votes
3 answers

Find class that implements generic interface with Ninject

With Ninject you can register a binding like this: Bind(typeof(IQueryHandler<,>)).To(typeof(QueryHandler<,>)); But in my case I don't know the name of the actual class. All i know is that it implements a certain interface. So for example, suppose I…
w00
  • 26,172
  • 30
  • 101
  • 147
2
votes
1 answer

ASP.NET MVC: No IUserTokenProvider is registered using Ninject

I am running into the error No IUserTokenProvider is registered on a call to _userManager.GenerateEmailConfirmationTokenAsync(user.Id); which is generating a token to be sent in an account registration e-mail. I have reviewed many posts related to…
GregH
  • 5,125
  • 8
  • 55
  • 109
2
votes
3 answers

How to create a base class that accepts parameters for controllers without changing child controllers?

I'm trying to add ninject to the following setup - public class BaseController : Controller { protected ILogger Logger {get;} public BaseController() { Logger = new MyLogger(); } } public class Controller1Controller : BaseController { ...…
Achilles
  • 1,099
  • 12
  • 29
2
votes
1 answer

Ninject is not working in custom validation attribubte in ASP.NET MVC

This question is the consequence of this question. I am developing an ASP.NET MVC Web Application. In my project I am doing remote validation using data annotation to my view model class. I know default remote attribute does not support server…
2
votes
1 answer

Ninject: Getting service doesn't work in my business layer

I searched a lot to solve the problem but no solution worked and I am new to DI and Ninject. My problem is that i can get my service in WebUi layer but i can not get my service in Business layer. This code work in my WebUi but it doesnt work in my…
Mashtani
  • 621
  • 11
  • 24
2
votes
1 answer

Nested Ninject Bindings - Dependency Injection

I have two classes (with similarly named interfaces): OuterService(IInnerService innerService) InnerService(string configurationKey) In my NinjectMvc3 class I have a binding for the IInnerService interface: kernel.Bind.ToMethod(c =>…
Nate Jenson
  • 2,664
  • 1
  • 25
  • 34
2
votes
1 answer

Get an object instance from Ninject from within _Layout.cshtml in MVC

In my master layout page, I need to access a SessionManager instance simply to display which user is logged in. I have it working as follows (_Layout.cshtml): @using Ninject @{ var kernel = new StandardKernel(); var sm =…
Laurence Frost
  • 2,759
  • 3
  • 28
  • 45