我刚刚将基于 MVC 的 Web 服务部署到 Azure。它在专用服务器上运行良好。它使用 Ninject。
部署到 Azure 时,我收到以下错误:
The IControllerFactory 'xxx.NinjectControllerFactory' did not return a controller for the name '<DeploymentName>'.
其中
我正在使用 NuGet 的最新版本的 Ninject (2.2.0.0)。我的理解是 1.x 中存在中等信任问题,但 2.x 中没有。
有人能指出我在这方面的正确方向吗?正如我所说,它在非 Azure 部署中运行良好 - 而且我在许多 MVC 3 Web 应用程序中使用了相同的代码,没有出现任何问题,因此它看起来确实像是一些特定于 Azure 的问题。
最佳答案
我知道一些使用 Ninject.MVC3 的项目在 Azure 上成功运行。您应该尝试使用此扩展,而不是实现您自己的 NinjectControllerFactory
。否则问题很可能出在您的 ControllerFactory 而不是 Ninject。
关于asp.net-mvc - 为什么 Ninject 在部署到 Azure 时会抛出 "did not return a controller"异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8791947/