C#学习笔记(视图)

来源:互联网 发布:郑州科技市场数据恢复 编辑:程序博客网 时间:2024/06/09 15:50

控制器转向视图的三种返回方法:

public class HomeController : Controller    {        public ActionResult Index()        {        //控制器返回到约定的页面 /Home/Index.cshtml        //mvc有隐式约定 ~/Views/控制器名称去掉Controller后缀/方法名称.cshtml                 return View();        //转向不同视图。/Home/NotIndex.cshtml            return View("NotIndex");        //转向完整路径视图。/Views/Example/Index.html            return View("~/Views/Example/Index.html");        }    }
原创粉丝点击