1

I've been scouring the Internet and learning how to enable an ASP.Net MVC 3 site to use MEF. The idea being to build a modular site, so we can expand features as needed. I have just about every piece of code working, but for some reason, when I'm trying to load my Index view from the Add-in, it's trying to load the _ViewStart.cshtml file from the Add-in, and not the main MVC site.

Has anyone run into this, and if so, what was the work around?

Richard B
  • 1,581
  • 1
  • 15
  • 31
  • Can you provide some more details about the location of your view files and the difference between what you're seeing and what you expect? – marcind Nov 29 '10 at 08:25
  • The view files were embedded resources in a *.dll. the *.dll was deployed in the ~/bin/ folder of a parent site. The cshtml page was being accessed as expected, but it seems as if the view engine was also accessing the virtualpathprovider to pull the __ViewStart.cshtml file. I'm wondering if maybe I needed to edit some path detection somewhere... Let me recreate the project, and once I get back to where I was at, I'll post a download here. – Richard B Nov 29 '10 at 18:51
  • It would be easier if you just posteda sample layout of your virtual as well a real files. If te virtual file is located under something like ~\views\home\index.cshtml then the behavior you are seeing is correct. The purpose of VirtualPathProvider is to merge to make physical and virtual paths indistinguishable. – marcind Nov 29 '10 at 19:55

2 Answers2

0

You do realize how the _ViewStart hierarchy is resolved don't you? Basically, the ViewStart closest in hierarchy to the view is given precedence for display. In your case, the viewstart in your addin is most likely to be displayed.

If you don't want that displayed, delete or remove it, and the next ViewStart up in the hierarchy will be given display precedence and it will display, be used, just like you want.

Let me know if this has been of use to you, because the way you described it, it is doing/working just like it is supposed to according to my understanding.

Erx_VB.NExT.Coder
  • 4,838
  • 10
  • 56
  • 92
0

If you use this method: http://www.chrisvandesteeg.nl/2010/11/22/embedding-pre-compiled-razor-views-in-your-dll/ to 'embed' your views (they're actually compiled), _viewstart will first be looked for in your physical path (so your main mvc site), and if it's not found there, it'll look for the file as a compiled resource in the dll