本文转载自:http://www.youarebug.com/forum.php?mod=viewthread&tid=91&extra=page%3D1
@{ ViewBag.Title ="Index"; } <h2>这是我的第一个文件</h2>
public static void RegisterRoutes(RouteCollectionroutes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default",// Route name "{controller}/{action}/{id}",// URL with parameters new{ controller = "Home", action = "Index", id = UrlParameter.Optional} // Parameter defaults ); }
public class HomeController : Controller { // // GET:/Home/ public ActionResult Index() { returnView(); } public ActionResult FirstMethod() { returnView(); } }
我们添加FirstMethod的对应视图,并写入我们的代码,代码如下
@{ ViewBag.Title = "FirstMethod"; } <h2>这是我的第一个ASP.NETMVC方法,FirstMethod</h2>
ASP.NET MVC3入门教程之第一个WEB应用程序,布布扣,bubuko.com
原文:http://www.cnblogs.com/whh306318848/p/3578827.html