简体   繁体   English

将 Umbraco 7 集成到现有的 MVC 4 Web 应用程序中

[英]Integrating Umbraco 7 into an existing MVC 4 Web application

This answer suggests that one should create a new project for Umbraco content management alongside the existing MVC application.这个答案表明应该在现有的 MVC 应用程序旁边为 Umbraco 内容管理创建一个新项目。 I have created the new project as suggested, and installed Umbraco into it through NuGet.我按照建议创建了新项目,并通过 NuGet 将 Umbraco 安装到其中。

So now I have 2 projects, one for my MVC application and one for CMS.所以现在我有 2 个项目,一个用于我的 MVC 应用程序,一个用于 CMS。 Both are working as expected, meaning that I can add contents through the Umbraco UI after building the newly created Umbraco project.两者都按预期工作,这意味着我可以在构建新创建的 Umbraco 项目后通过 Umbraco UI 添加内容。

My question is, how can I query the content from inside the MVC application in order to show the manageable content on my views?我的问题是,如何从 MVC 应用程序内部查询内容以便在我的视图中显示可管理的内容? It seems that it can be done through theUmbraco REST API , but as both databases (for the MVC application and the CMS application) will reside on the same server this seems unefficient.似乎可以通过Umbraco REST API 完成,但是由于两个数据库(用于 MVC 应用程序和 CMS 应用程序)将驻留在同一服务器上,这似乎效率不高。

Traditionally one of the problems with Umbraco is that it is not a pure MVC architecture.传统上,Umbraco 的问题之一是它不是纯 MVC 架构。 This means that people are sometimes led to believe they will be able to implement a 100% MVC solution and then just manage their content through Umbraco.这意味着人们有时会相信他们将能够实施 100% MVC 解决方案,然后只需通过 Umbraco 管理他们的内容。

The bad news is that you've found out the main issue with Umbraco so far.坏消息是,到目前为止,您已经发现了 Umbraco 的主要问题。 Namely that it doesn't render things using the standard MVC rendering engine.也就是说,它不使用标准的 MVC 渲染引擎来渲染东西。 It has to use custom controllers to retrieve view-models, such as SurfaceControllers or UmbracoApiControllers (as mentioned by your example of using REST services to return the page data).它必须使用自定义控制器来检索视图模型,例如SurfaceControllers或 UmbracoApiControllers(如您使用 REST 服务返回页面数据的示例所述)。

The good news is that things are getting better.好消息是情况正在好转。 Version 7.3.0 will be the first version to be bundled with MVC 5 as standard. 7.3.0 版将是第一个与 MVC 5 作为标准捆绑在一起的版本。 Check out the beta version here to see if it is more suitable for your needs.在此处查看测试版,看看它是否更适合您的需求。 Of course you may need to upgrade your MVC project to MVC 5 too.当然,您可能也需要将 MVC 项目升级到 MVC 5。

Hopefully with 7.3.0 you'll be good.希望 7.3.0 你会很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM