1

The DefaultControllerFactory contains three different methods:

  1. GetControllerInstance
  2. CreateController
  3. GetControllerType

When is each method executed in the request lifetime? I've seen custom controller factories where one of these methods is overridden and implemented but I can't seem to find details on the execution path of each one.

2 Answers 2

2

CreateController gets called.
It first calls GetControllerType to figure out type of the controller, then passes this type to GetControllerInstance.

Because it is easier (and often enough) to (only) override GetControllerInstance (so that the logic behind selecting the type remains the same), you'd often see this happening.

Sign up to request clarification or add additional context in comments.

Comments

1

Update for MVC3, the methods are called in this order.

GetControllerType gets called first and gets called twice.

  1. GetControllerType
  2. GetControllerSessionBehavior
  3. CreateController
  4. GetControllerType
  5. CreateControllerInstance
  6. ReleaseController

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.