ninject.web.mvc

Ninject.MVC5 Release Scope Never Called - OutOfMemoryException

白昼怎懂夜的黑 提交于 2019-12-11 05:00:42
问题 I'm new to Ninject, but I've become convinced that the out of the box configuration for Ninject.MVC5 NuGet package never actually releases the objects scoped to the HttpContext. I consistently get an OutOfMemoryException after a bout of repeated heavy memory usage by some of my larger reports. So to prove I wasn't losing my mind I created an empty test project. I created a default project in VS 2017 by File -> New Project -> C# -> Web -> ASP.NET Web Application -> MVC (in the modal). This is

ASP.NET MVC Error loading Ninject component ICache

倖福魔咒の 提交于 2019-12-11 04:09:19
问题 I've been getting the following error: System.InvalidOperationException: Error loading Ninject component ICache No such component has been registered in the kernel's component container. Using the following NuGet packages: Ninject 3.0.1.10 Ninject.MVC3 3.0.0.6 Ninject.Web.Common 3.0.0.7 ASP.NET MVC 4.0.30506.0 The Binding are setup using WebActivator and the Ninject Bootstrapper (default setup). It appears this error was once an issue before Ninject 2.2.1.0 and Ninject.MVC3 2.2.1.0 were

Validation Attribute get triggered two times

我是研究僧i 提交于 2019-12-11 03:45:36
问题 In my MVC3 application I have the model ( not important properties deleted ): public class AccountViewModel { [StringLength(65)] public string Property1 { get; set; } [StringLength(65)] public string Property2 { get; set; } } The problem is when an action is submited validation attribute called twice, and I can get 4 errors in summary, instead of 2: 'Property1' length must be less than 65 characters 'Property1' length must be less than 65 characters 'Property2' length must be less than 65

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

丶灬走出姿态 提交于 2019-12-11 01:57:26
问题 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 validation. I can validate it again in action method. But I do not want to do that it is violating separation of concerns. So I tried to create custom server client remote validation attribute. I found a code online and I used it. But it is giving me

Problem with Ninject and MVC3 Dependency injection action filter on Controller and Action

我是研究僧i 提交于 2019-12-09 19:00:42
问题 Recently I decided to remove a heap of action level filters in a controller and replace them with a single controller level filter. Now I'm getting this error message. Error activating LogActionFilter More than one matching bindings are available. Activation path: 1) Request for LogActionFilter Suggestions: 1) Ensure that you have defined a binding for LogActionFilter only once. I'm sure the error is related to action filter being bound twice, as that's what I've changed. However, when I view

No matching bindings are available, and the type is not self-bindable in Ninject

可紊 提交于 2019-12-09 15:34:55
问题 I am using Ninjec, Ninject.Web.MVC and Ninject.Web.Common When I start my mvc application I get this binding error: What do I wrong in my binding? Error activating DbConnection No matching bindings are available, and the type is not self-bindable. Activation path: 4) Injection of dependency DbConnection into parameter existingConnection of constructor of type DbContext 3) Injection of dependency DbContext into parameter dbContext of constructor of type GenericRepository{User} 2) Injection of

Inheriting a base controller with constructor

喜你入骨 提交于 2019-12-08 05:11:15
问题 I am using ninject to inject my repositories. I would like to have a my base class to be inherited but I cant because it has a constructor. Base Controller: namespace Orcha.Web.Controllers { public class BaseController : Controller { public IRepository<string> db; public BaseController(Repository<string> db){ this.db = db; Debug.WriteLine("Repository True"); } } } Controller with inherit: Error 'BaseController' does not contain a constructor that takes 0 arguments HomeController.cs public

How to manually instantiate objects using Ninject for MVC 3

寵の児 提交于 2019-12-07 14:04:44
问题 How is it possible to use Ninject inside ASP.NET MVC 3 to instantiate objects manually? Something as "NinjectObject".Resolve<IMyService>(); Thank you & regards 回答1: It is better to inject dependencies instead of resolving them. Service Locator is an anti-pattern. You could for example use the following: IMyService myService = DependencyResolver.Current.GetService<IMyService>(); But please do not use it. That's an anti-pattern. Dependency injection is the preferred way. You should have the

How to resolve error :the type does not appear to implement microsoft.practices.servicelocation.iservicelocator?

倾然丶 夕夏残阳落幕 提交于 2019-12-06 17:52:43
问题 I am new to MVC, i am following " PRO ASP.NET MVC 4 by Adam Freeman ". I am currently working on its 6th chapter. In which i am learning how to use Ninject in MVC 4 for Dependency Injection. I have created the application as described in the book. Now i am not getting why the following Error Comes: the type does not appear to implement microsoft.practices.servicelocation.iservicelocator Here is my Controller code: public class HomeController : Controller { private Product[] products = { new

Inheriting a base controller with constructor

一曲冷凌霜 提交于 2019-12-06 15:50:47
I am using ninject to inject my repositories. I would like to have a my base class to be inherited but I cant because it has a constructor. Base Controller: namespace Orcha.Web.Controllers { public class BaseController : Controller { public IRepository<string> db; public BaseController(Repository<string> db){ this.db = db; Debug.WriteLine("Repository True"); } } } Controller with inherit: Error 'BaseController' does not contain a constructor that takes 0 arguments HomeController.cs public class HomeController : BaseController { public ActionResult Index() { ViewBag.Message = "Welcome to ASP