首页 > 解决方案 > 由于通用基本控制器,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”

如果我删除类定义的通用元素,错误就会消失。谁能告诉我为什么我不能摆脱这个错误?

它是一种跨多个控制器显示通用表单的操作方法,因此我希望它通用用于缓存的序列化和反序列化。

任何帮助表示赞赏。

标签: c#asp.net-mvcgenerics

解决方案


PartialViewController. 您BaseController不继承自Controller,因此它无法访问您期望的方法。


推荐阅读