Skip to content

Introduction

介绍

The library Orchard Core Modules provides a mechanism to have a self-contained modular system where you can opt into a specific application framework and not have the design of your application be dictated to by such.

图书馆Orchard核心模块提供了一种机制,可以拥有一个独立的模块化系统,您可以选择加入特定的应用程序框架,而不必依赖于您的应用程序设计。

Getting started

入门

In Visual Studio, create a new web application.

在Visual Studio中,创建一个新的Web应用程序。

Install OrchardCore.Application.Cms.Targets into the project by managing the project NuGet packages.

通过管理项目NuGet包将“OrchardCore.Application.Cms.Targets”安装到项目中。

Next, within Startup.cs, modify the ConfigureServices method, add this line:

接下来,在Startup.cs中,修改ConfigureServices方法,添加以下行:


services.AddOrchardCms();

 <font color=#0099ff size=4 face="黑体">services.AddOrchardCms();</font> 


Next, at the end of the Configure method, replace this block:

接下来,在Configure方法的末尾,替换此块:


app.Run(async (context) =>

 <font color=#0099ff size=4 face="黑体">app.Run(async(context)=></font> 


{

 <font color=#0099ff size=4 face="黑体">{</font> 


    await context.Response.WriteAsync("Hello World!");

});

 <font color=#0099ff size=4 face="黑体">});</font> 


with this line:

用这一行:


app.UseOrchardCore();

 <font color=#0099ff size=4 face="黑体">app.UseOrchardCore();</font> 


Additional frameworks

其他框架

You can add your favourite application framework to the pipeline, easily. The below implementations are designed to work side by side, so if you want Asp.Net Mvc and Nancy within your pipeline, just add both.

您可以轻松地将喜爱的应用程序框架添加到管道中。以下实现旨在并行工作,因此如果您想在管道中使用Asp.Net Mvc和Nancy,只需添加两者即可。

The modular framework wrappers below are designed to work directly with the modular application framework, so avoid just adding the raw framework and expect it to just work.

下面的模块化框架包装器被设计为直接与模块化应用程序框架一起工作,因此避免添加原始框架并期望它只是工作。

Asp.Net Mvc

Asp.Net Mvc

Install OrchardCore.Application.Mvc.Targets into the project by managing the project NuGet packages.

通过管理项目NuGet包将“OrchardCore.Application.Mvc.Targets”安装到项目中。

Next, within Startup.cs, modify the method ConfigureServices to look like this:

接下来,在Startup.cs中,将方法ConfigureServices修改为如下所示:


            // Add ASP.NET MVC and support for modules

            services

                .AddOrchardCore()

                .AddMvc()

                ;

Note

!注意

Note the addition of `.AddMvc()`

Asp.Net Mvc is now part of your pipeline.

Asp.Net Mvc现在是您管道的一部分。

You can find a sample application here: OrchardCore.Mvc.Web

你可以在这里找到一个示例应用程序:[OrchardCore.Mvc.Web](../../../ OrchardCore.Mvc.Web / Startup.cs)

NancyFx

NancyFx

Install OrchardCore.Application.Nancy.Targets into the project by managing the project NuGet packages.

通过管理项目NuGet包将“OrchardCore.Application.Nancy.Targets”安装到项目中。

Next, within Startup.cs, modify the method ConfigureServices to look like this:

接下来,在Startup.cs中,将方法ConfigureServices修改为如下所示:


            // Add Nancy and support for modules

            services

                .AddOrchardCore()

                .AddNancy()

                ;

);

 <font color=#0099ff size=4 face="黑体">);</font> 


Note

!注意

Note the addition of `.AddNancy()`

NancyFx is now part of your pipeline. What this means is that Nancy modules will be automatically discovered.

NancyFx现在是您管道的一部分。这意味着南希模块将被自动发现。

You can find an sample application here: OrchardCore.Nancy.Web

你可以在这里找到一个示例应用程序:[OrchardCore.Nancy.Web](../../../ OrchardCore.Nancy.Web / Startup.cs)