Asp.net Mvc:Ninject - IPrincipal
我想知道如何使用 Ninject 将 IPrincipal 绑定到 Asp.net Mvc 中的 HttpContext.Current.User 。
友好的问候,
Pickels
编辑:
不确定这是否重要,但我使用我自己的 CustomPrincipal 类。
I was wondering how I could bind the IPrincipal to HttpContext.Current.User in Asp.net Mvc with Ninject.
Friendly greetings,
Pickels
Edit:
Not sure if it matters but I use my own CustomPrincipal class.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无需在
NinjectModule
中使用提供程序即可执行此操作:注意,我添加了
.InRequestScope()
以确保每个 HTTP 请求都会缓存该方法的值一次。即使您使用提供程序机制,我也建议这样做。You can do this without the need for a provider in your
NinjectModule
:Note, I included
.InRequestScope()
to ensure that the value of the method is cached once per HTTP request. I'd recommend doing so even if you use the provider mechanism.我想我明白了:
在我的 NinjectModule 中我做到了:
如果这是错误或不完整的,请告诉我,我会调整/删除。
Think I got it:
And in my NinjectModule I do:
If this is wrong or not complete please let me know and I'll adjust/delete.