基本控制器错误?

时间:2015-08-12 10:55:31

标签: asp.net-mvc inheritance

我想跑#34; HELLO"但它只运行" BYE"线。 (1个BaseController用于许多其他控制器,重用代码) 帮助我,谢谢

public class BaseController : Controller
{
    public virtual ActionResult Index()
    {
        string str="HELLO";

        return View();            
    }
}


public class TestController : BaseController
{
    public override ActionResult Index()
    {
        string str="BYE";

        return View();
    }
}   

1 个答案:

答案 0 :(得分:0)

public class TestController : BaseController
{
    public override ActionResult Index()
    {
        return base.Index();
    }
}