Set default scope to InRequestScope for ASP MVC app

440 views
Skip to first unread message

Brian Beard

unread,
May 9, 2012, 12:21:06 PM5/9/12
to nin...@googlegroups.com
I am currently using Ninject 3 in an ASP MVC application. What is the best way for me to setup the kernel so that the default scope is the Request scope? Currently I'm having to setup all my bindings similar to the following:

kernel.Bind<IRepository>().To<SqlRepository>().InRequestScope();

Remo Gloor

unread,
May 10, 2012, 1:58:02 PM5/10/12
to nin...@googlegroups.com
You can't! But you can use conventions to reduce the configuration.

Am 10.05.2012 um 19:55 schrieb "Brian Beard" <brian...@onspring.com>:

I am currently using Ninject 3 in an ASP MVC application. What is the best way for me to setup the kernel so that the default scope is the Request scope? Currently I'm having to setup all my bindings similar to the following:

kernel.Bind<IRepository>().To<SqlRepository>().InRequestScope();

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ninject/-/n4cOtB6HOFcJ.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ninject?hl=en.

Jarrett Meyer

unread,
May 10, 2012, 3:03:18 PM5/10/12
to nin...@googlegroups.com
Would that be very difficult to do?  https://github.com/ninject/ninject/pull/55 My solution is a bit of a hack, but it looks like it would work.

--
Jarrett Meyer
Email: jarret...@gmail.com
Web: JarrettMeyer.com
Twitter: @jarrettmeyer

Remo Gloor

unread,
May 11, 2012, 1:04:49 PM5/11/12
to nin...@googlegroups.com
No it is not difficult. I just never gave this a high enough priority to appear on the top of the todo list because this is not really an issue when using conventions.

Am 10.05.2012 um 21:03 schrieb "Jarrett Meyer" <jarret...@gmail.com>:

Would that be very difficult to do?  https://github.com/ninject/ninject/pull/55 My solution is a bit of a hack, but it looks like it would work.

--
Jarrett Meyer
Email: jarret...@gmail.com
Web: JarrettMeyer.com
Twitter: @jarrettmeyer



On Thu, May 10, 2012 at 1:58 PM, Remo Gloor <remo....@bbv.ch> wrote:
You can't! But you can use conventions to reduce the configuration.

Am 10.05.2012 um 19:55 schrieb "Brian Beard" <brian...@onspring.com>:

I am currently using Ninject 3 in an ASP MVC application. What is the best way for me to setup the kernel so that the default scope is the Request scope? Currently I'm having to setup all my bindings similar to the following:
kernel.Bind<IRepository>().To<SqlRepository>().InRequestScope();

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To view this discussion on the web visit https://groups.google.com/d/msg/ninject/-/n4cOtB6HOFcJ.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ninject?hl=en.

--
You received this message because you are subscribed to the Google Groups "ninject" group.
To post to this group, send email to nin...@googlegroups.com.
To unsubscribe from this group, send email to ninject+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/ninject?hl=en.
Reply all
Reply to author
Forward
0 new messages