Api Orchard Core asp net Core Web应用程序中的Http Post返回错误请求

Api Orchard Core asp net Core Web应用程序中的Http Post返回错误请求,api,asp.net-core,orchardcore,Api,Asp.net Core,Orchardcore,我在asp net core web应用程序项目中使用Orchard core。我有一个带有两个简单get和postapi的控制器。由于我使用的是OrchardCore,Startup.cs文件的配置不同,我不在configureServices中使用services.AddControllers()。 在我使用HttpGet之前,一切都很好。但是当我想要一个带有HttpPost的Api时,postMan会说badRequest。所以我在Startup.cs中添加了services.AddCon

我在asp net core web应用程序项目中使用Orchard core。我有一个带有两个简单get和postapi的控制器。由于我使用的是OrchardCore,Startup.cs文件的配置不同,我不在configureServices中使用services.AddControllers()。 在我使用HttpGet之前,一切都很好。但是当我想要一个带有HttpPost的Api时,postMan会说badRequest。所以我在Startup.cs中添加了services.AddControllers(),在PostMan中的PostAPI很好,但orchard项目说我有多个端点。 我使用了services.AddMvc().AddNewtonsoftJson(),一切正常,但管理员页面没有加载,出现如下错误:

InvalidOperationException:未找到视图“索引”。这个 搜查了以下地点: /Areas/OrchardCore.AdminDashboard/Views/Dashboard/Index.cshtml /Areas/OrchardCore.AdminDashboard/Views/Shared/Index.cshtml /视图/Shared/Index.cshtml/Pages/Shared/Index.cshtml

如果您能帮助我如何调用PostAPI,我将不胜感激。 这是我的密码:

[HttpPost("post")]
    public Task<string> post()
    {
        return Task.FromResult("hiPost");
    }

    [HttpGet("get")]
    public Task<string> get()
    {
        return Task.FromResult("hiGet");
    }

控制器上可能缺少
IgnoreAntiForgeryToken
属性

OrchardCore

对于
OrchardCore
中的
ApiController
,我希望看到控制器装饰如下

[ApiController]
[Authorize(AuthenticationSchemes = "Api"), IgnoreAntiforgeryToken, AllowAnonymous]
但是,这取决于您是使用
OpenId
模块进行身份验证,还是只需要在没有
AuthenticationScheme


根据您在现实生活中实际发布的内容,在您的帖子中提供防伪令牌可能会更好。

这太不可思议了……非常感谢
[ApiController]
[Authorize(AuthenticationSchemes = "Api"), IgnoreAntiforgeryToken, AllowAnonymous]