小编Den*_* W.的帖子

在核心 3.0 中将视图渲染为字符串:找不到与 ActionContext 关联的 IRouter

我想要的是:

在我的应用程序中,我想为我的电子邮件使用模板。不幸的是,我之前在另一个项目中使用的代码不再起作用。

抛出的错误:

Could not find an IRouter associated with the ActionContext. 

If your application is using endpoint routing then you can get a IUrlHelperFactory with dependency injection 
and use it to create a UrlHelper, or use Microsoft.AspNetCore.Routing.LinkGenerator.'
Run Code Online (Sandbox Code Playgroud)

我不知道如何解决这个问题,因为我找不到任何方法来注入IUrlHelper. 我不确定为什么甚至需要这样做,因为无论如何它都不在视图中。

字符串渲染方法:

Could not find an IRouter associated with the ActionContext. 

If your application is using endpoint routing then you can get a IUrlHelperFactory with dependency injection 
and use it to create a UrlHelper, or use Microsoft.AspNetCore.Routing.LinkGenerator.'
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core asp.net-core-3.0

10
推荐指数
1
解决办法
4328
查看次数

标签 统计

asp.net-core ×1

asp.net-core-3.0 ×1

c# ×1