MVC 3 插件视图尝试从插件解析 _ViewStart.cshtml

发布于 2024-10-05 05:07:51 字数 204 浏览 3 评论 0原文

我一直在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟若柳尘 2024-10-12 05:07:51

您确实意识到 _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.

凉城已无爱 2024-10-12 05:07:51

如果您使用此方法:
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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文