This is what I did:

 * Create the following contorller factory:

 public class WindsorControllerFactory : DefaultControllerFactory
    {
        private readonly IKernel _container;

        public WindsorControllerFactory(IKernel container)
        {
            _container = container;
        }

protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, System.Type controllerType)
        {
            if(controllerType == null)
            {
                throw new HttpException(404, "Controller not found.");
            }
            return _container.Resolve(controllerType) as IController;
        }
    }

 * Instruct MVC to make use of this controller factor by adding the
   following in the method Application_Start in the file Global.asax.cs
   I instructed:

ControllerBuilder.Current.SetControllerFactory(Container.Resolve<IControllerFactory>());

I'm not sure if this is the best way to do it, but it works.


Kind regards,
Merijn

On 11-10-2012 10:52, Wayne Douglas wrote:
so i'd still need a controller factory and all that?

I thought the whole point was that they had integrated it all better
so we won't need all that? With the whole DependencyResolver thing no?

On Thu, Oct 11, 2012 at 9:50 AM, Krzysztof Kozmic
<[email protected]> wrote:
I don't think it would be much different from MVC3...

--
Krzysztof Kozmic

On Thursday, 11 October 2012 at 6:49 PM, Serdar B. wrote:

It would be really nice if there is another "tobeseen" example for mvc4 :)

* including general exception interceptor

Serdar
--
serdarb.com


On Thu, Oct 11, 2012 at 11:43 AM, Wayne Douglas <[email protected]>
wrote:

Hi

Does anyone have any pointers to getting the container wired up in
MVC4? I also understand the process differs slightly for web and web
api?

Googling seems to come up with controller factories which to my
understanding are not necessary in mvc 4?

--
Cheers,

w://

--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.


--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.


--
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en.




--

Dr. Merijn de Jonge
Chief Software Development


T       +31 6 51442504 /
E       [email protected] <mailto:[email protected]> /
W       www.sorama.eu <http://www.sorama.eu> /
Twitter logo    @MerijnDeJonge <https://twitter.com/MerijnDeJonge> /

        

Sorama op Twitter <http://twitter.com/#%21/Sorama_eu>
Sorama Nieuwsbrief <http://eepurl.com/G0xt>


Den Dolech 2, Gemini-Noord -1.65 /
5612 AZ / Eindhoven /
The Netherlands /
Chamber of Commerce Eindhoven nr. 50232053 /

        Sorama logo

The information contained in this message is confidential and may be legally privileged. The message is intended solely for the addressee(s). If you are not the intended recipient, you are hereby notified that any use, dissemination, or reproduction is strictly prohibited and may be unlawful. If you are not the intended recipient, please contact the sender by return e-mail and destroy all copies of the original message.

--
You received this message because you are subscribed to the Google Groups "Castle 
Project Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/castle-project-users?hl=en.

<<inline: twitter-bird-16x16.png>>

<<inline: sorama.png>>

Reply via email to