[英]AspNetCore InvalidOperationException
I am getting the following error:我收到以下错误:
System.InvalidOperationException: Unable to resolve service for type
'Microsoft.AspNetCore.NodeServices.INodeServices' while attempting to activate
'ConvertHighchart.Controllers.runNodeScriptController'.
My controller code is this:我的 controller 代码是这样的:
using Microsoft.AspNetCore.NodeServices;
using Microsoft.AspNetCore.Mvc;
using System.Threading.Tasks;
namespace ConvertHighchart.Controllers
{
[ApiController]
[Route("[controller]")]
public class runNodeScriptController : ControllerBase
{
private readonly INodeServices _nodeServices;
public runNodeScriptController(INodeServices nodeServices)
{
_nodeServices = nodeServices;
}
[HttpPost]
public async Task<IActionResult> Post()
{
var result = "";
try
{
result = await _nodeServices.InvokeExportAsync<string>("test_nodejs_script",
"generateHighChart",
"abc");
}
catch (System.Exception ex)
{
}
return Ok(result);
}
}
}
Thanks谢谢
If you see this error while sending POST requests to the endpoint, have you put services.AddNodeServices();
如果您在向端点发送 POST 请求时看到此错误,您是否将services.AddNodeServices();
in Startup?在启动?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.