Is there any way I can inject / build up dependencies on a _ViewStart class without calling my service locator directly?
Thanks
Ben
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I don’t understand how you can inject your settings when the _ViewStart class (System.Web.Mvc.ViewStartPage) doesn’t have a property to hold them.
Assuming you’re trying to avoid fetching your settings in _ViewStart, a possible solution would be to create a custom ViewStartPage class that has a property for your settings, and call the service locator from within there:
To use this, you need to set the base class in your _ViewStart:
There doesn’t seem to be (or certainly I can’t find) a way to set the base class for this in Web.config like you can with basePageType 🙁