简体   繁体   English

有没有办法让基本视图组件ASP.NET Core?

[英]Is there any way to make base view component ASP.NET Core?

In rc1 you can make BaseViewComponent and then inherit it and use it without any problems like baseController, but after migrating my project to rc2 I recieve that error Could: not find an 'Invoke' or 'InvokeAsync' method for the view component 'ForumSystem.Web.ViewComponents.BaseViewComponent'. 在rc1中你可以创建BaseViewComponent,然后继承它并使用它而不会出现像baseController这样的问题,但是在将我的项目迁移到rc2后我收到了错误可能:找不到视图组件'ForumSystem的'Invoke'或'InvokeAsync'方法。 Web.ViewComponents.BaseViewComponent”。
Is there any way to do that in rc2? 在rc2中有没有办法做到这一点?

Having the same problem I red the documentation and found that "view components must be public, non-nested, and non-abstract classes", so I made my base class abstract and this solved my problem. 遇到同样的问题,我重新编写文档,发现“视图组件必须是公共的,非嵌套的和非抽象的类”,所以我将我的基类抽象化,这解决了我的问题。 This is a workaround and not a solution for everyone, but worked for me. 这是一种解决方法,并不是每个人的解决方案,但为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM