ASP.NET MVC - 控制器
为了学习 ASP.NET MVC建一个 Internet
部分 4:。
Controllers 文件夹
Controllers 类。
MVC 必须以 "Controller" 结尾。
子中,Visual Web Developer 文件:HomeController.cs)和 AccountController.cs 页面):
web URL 某个 URL "http://www.51help.tk/index.asp" "index.asp"。
MVC 同。MVC 将 URL ”。
客户端。
Home 控制器
器文件 HomeController.cs个控件 Index 和 About。
把 HomeController.cs 替换为:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcDemo.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{return View();}
public ActionResult About()
{return View();}
}
}
Controller 视图
Views 文件 Index.cshtml 和 About.cshtml 器中的 ActionResult 视图 Index() 和 About()。