翼度科技»论坛 编程开发 .net 查看内容

orchard core 搭建cms 加载其他模块的管理1

8

主题

8

帖子

24

积分

新手上路

Rank: 1

积分
24
有一个具体的例子 :https://github.com/OrchardCMS/OrchardCore.Samples
1、先使用教程,安装cms -可以是完全 也可以是采用前后端分离管理。
修改对应的program.cs 的内容:
`var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
//builder.Services.AddRazorPages();
builder.Services.AddOrchardCore();
//这是为了 识别其他模块的mvc路径
builder.Services.AddOrchardCore().AddMvc();
// cms
builder.Services.AddOrchardCms().AddMvc();
//builder.Services.AddMvc();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
//原本自带的路由跟授权要注释掉,使用orchardcore的路由跟页面
//app.UseRouting();
//app.UseAuthorization();
//app.MapRazorPages();
//这里是使用orchardcore的
app.UseOrchardCore();
app.Run();
`
对应添加引用






然后要添加的其他net core项目  比如新建一个webapi项目
然后添加引用

其他都不需要变。
再到刚才的cms的项目中 添加webapi的项目引用即可调用它。  可
以在后台管理中开启。或者禁用  类似如下图

这样就可以使用到该项目的路由,通常是需要加该项目的前缀。 这是约定。
也可以在控制器里面 定义 [Route("xxx/[controller]")]
route 的设置会直接忽略项目前缀。   尽量不要跟主cms的路由冲突,比如 admin 就不要设置了。

来源:https://www.cnblogs.com/zxs-onestar/archive/2023/10/17/17769254.html
免责声明:由于采集信息均来自互联网,如果侵犯了您的权益,请联系我们【E-Mail:cb@itdo.tech】 我们会及时删除侵权内容,谢谢合作!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

举报 回复 使用道具