MVC 3 插件视图尝试从插件解析 _ViewStart.cshtml
我一直在 Internet 上搜索并学习如何使 ASP.Net MVC 3 站点能够使用 MEF。我们的想法是构建一个模块化站点,以便我们可以根据需要扩展功能。我几乎每一段代码都在工作,但由于某种原因,当我尝试从加载项加载索引视图时,它会尝试从加载项加载 _ViewStart.cshtml 文件,而不是主文件MVC 站点。
有没有人遇到过这个问题,如果是的话,解决办法是什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确实意识到 _ViewStart 层次结构是如何解析的,不是吗?基本上,在层次结构中最接近视图的 ViewStart 会优先显示。在您的情况下,您的插件中的 viewstart 最有可能显示。
如果您不希望显示该内容,请将其删除或移除,并且层次结构中的下一个 ViewStart 将获得显示优先级,并且它将按照您想要的方式显示、使用。
让我知道这是否对您有用,因为按照您描述的方式,它的运行/工作方式就像根据我的理解应该的那样。
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.
如果您使用此方法:
http://www. chrisvandesteeg.nl/2010/11/22/embedding-pre-compiled-razor-views-in-your-dll/
要“嵌入”您的视图(它们实际上是编译的),首先将在您的物理路径(因此您的主 mvc 站点)中查找 _viewstart,如果在那里找不到它,它将查找该文件作为已编译的资源在dll中
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