ASP.NET MVC - ¿ØÖÆÆ÷

ΪÁËѧϰ ASP.NET MVC£¬ÎÒÃǽ«¹¹½¨Ò»¸ö Internet Ó¦ÓóÌÐò¡£

²¿·Ö 4£ºÌí¼Ó¿ØÖÆÆ÷¡£

Controllers Îļþ¼Ð

Controllers Îļþ¼Ð°üº¬¸ºÔð´¦ÀíÓû§ÊäÈëºÍÏìÓ¦µÄ¿ØÖÆÆ÷Àà¡£

MVC ÒªÇóËùÓпØÖÆÆ÷µÄÃû³Æ±ØÐëÒÔ "Controller" ½áβ¡£

ÔÚÎÒÃǵÄÀý×ÓÖУ¬Visual Web Developer ÒÑ´´½¨ÒÔÏÂÎļþ£ºHomeController.cs£¨ÓÃÓÚÊ×Ò³ºÍ¹ØÓÚÒ³Ãæ£©ºÍ AccountController.cs £¨ÓÃÓÚµÇÂ¼Ò³Ãæ£©£º

web ·þÎñÆ÷ͨ³£»á½«½øÈëµÄ URL ÇëÇóÖ±½ÓÓ³Éäµ½·þÎñÆ÷ÉϵĴÅÅÌÎļþ¡£ÀýÈ磺ij¸ö URL ÇëÇ󣨱ÈÈç "http://www.w3school.com.cn/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()¡£

VUE