I am using ASP.NET Webforms and in one page I want to make an AJAX call to a web method in the code behind. The problem is that web methods are static and I can\'t access page v
somwhere in your application is a singleton of Ninject. reference this singleton within the webmethod. a similar process is being do in Ninject.Web.PageBase.
You can directly retrieve it from the kernel using the IKernel.Get<T>()
method:
[WebMethod]
public static string DoSomething()
{
NinjectModule module = new YourModule();
IKernel kernel = new StandardKernel(module);
var controller = kernel.Get<ISecurityController>();
controller.WriteToLog();
}