Controller 如何知道要返回哪些 View ?我认为这是按照命名约定,但我见过一些实例,例如在 Nerd Dining 应用程序中,名称不匹配。在哪里或如何查看此映射?谢谢。
最佳答案
public class EmployeesController
{
public ViewResult Index()
{
return View("CustomerName");
}
}
将搜索:
Views/Employees/CustomerName.aspx
Views/Employees/CustomerName.ascx
Views/Shared/CustomerName.aspx
Views/Shared/CustomerName.ascx
差不多就是这样了..
当你刚刚返回View()时;在不指定名称的情况下,它会搜索与 Controller 操作同名的 View 。在本例中,Index.aspx
关于asp.net mvc - View 和 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1239308/