c# - 由于通用基本控制器,PartialView 无法识别错误
问题描述
我有以下控制器定义
public class BaseController<T> where T : Controller, new()
{
public ActionResult ShowACommonForm(T item)
{
//item is cached here
var model = new model()
return Partialiew(model);
}
我收到以下错误当前上下文中不存在名称“Partialiew”
如果我删除类定义的通用元素,错误就会消失。谁能告诉我为什么我不能摆脱这个错误?
它是一种跨多个控制器显示通用表单的操作方法,因此我希望它通用用于缓存的序列化和反序列化。
任何帮助表示赞赏。
解决方案
PartialView是Controller
. 您BaseController
不继承自Controller
,因此它无法访问您期望的方法。
推荐阅读
- graphql - GraphQL + Java 如何在查询解析器类中获取查询字符串?
- java - 我需要删除 ArrayList 中可能出现多次的特定元素
- java - 如何使用 TestNG 测试依赖于环境变量的代码?
- c# - 如何比较一个 SortedDictionary 中的值以将它们添加到新的 SortedDictionary?
- python - Matplotlib 循环遍历 seaborn 图中的轴以获取多个子图
- fullcalendar - 我的网站上的 fullcalendar 上只显示了来自 google 日历的一项活动
- javascript - 调试器检查的代码在 console.log 中显示正确的返回值,那么为什么我返回未定义?
- html - 如何修复不在wordpress中居中的菜单
- matlab - 如何更改 Matlab 代码以便 imshow() 函数显示正确的颜色?
- python - 如何使用 Selenium 更改 Chrome 的音量