The MVC framework – customizing the search locations
In the last post, we’ve seen what view engines do and how the WebFormViewEngine is responsible for initiating the properties that specify the places where the views (ASP.NET pages and user controls) are supposed to be located. At the time, I mentioned how you could register your own engine, but I forgot to point that you can easilly use that info to customize the place where your views are searched. So, if you don’t like the current restrictions but you do want to use ASP.NET pages and user controls, you can always inherit from the VirtualPathProviderViewEngine and build the array with the new locations from within the constructor of your new class.
Another thing I didn’t mention was that the VirtualPathProviderViewEngine uses caching for saving path info. This means that after finding the path to a view, it will add it to the cache and in future requests it will just return the path that exists there. In future versions you should be seing a plugable cache provider in the API of the class (meaning that you will be able to pass your own custom cache instances).
Ok, now we’re ready to keep going and the next post will be about the WebFormView class. Keep tuned!