mirror of
https://github.com/rudollee/LearningMVC.git
synced 2026-08-11 16:32:55 +00:00
Ch. 15 URL Routing (until 15-32)
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace UrlsAndRoutes.Controllers
|
||||
{
|
||||
public class AdminController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.Controller = "Admin";
|
||||
ViewBag.Action = "Index";
|
||||
return View("ActionName");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace UrlsAndRoutes.Controllers
|
||||
{
|
||||
public class CustomerController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.Controller = "Customer";
|
||||
ViewBag.Action = "Index";
|
||||
return View("ActionName");
|
||||
}
|
||||
|
||||
public ActionResult List()
|
||||
{
|
||||
ViewBag.Controller = "Customer";
|
||||
ViewBag.Action = "List";
|
||||
return View("ActionName");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace UrlsAndRoutes.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
public ActionResult Index()
|
||||
{
|
||||
ViewBag.Controller = "Home";
|
||||
ViewBag.Action = "Index";
|
||||
return View("ActionName");
|
||||
}
|
||||
|
||||
public ActionResult CustomVariable(string id = "DefaultId")
|
||||
{
|
||||
ViewBag.Controller = "Home";
|
||||
ViewBag.Action = "CustomVariable";
|
||||
ViewBag.CustomVariable = id; // ?? "<no value>"; // id; // RouteData.Values["id"];
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user