我不确定 Areas 是 VS11 还是 MVC4 的一部分,但它似乎非常适合组织一个大项目。但是我在链接到区域中的 Controller 时遇到了麻烦。
编辑:现在可以使用并且代码已更新
这里有我项目的截图http://www.gratisimage.dk/graphic/images/2011/October/30/724D_4EAD44CD.jpg
我有 2 个链接
@Html.ActionLink("Create Vehicle", "CreateVehicle", "Vehicle", new { area = "Units" }, null)
@Html.ActionLink("Index", "Index", "Vehicle", new { area = "Units" }, null)
还有我的 Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace unoeurotest.Areas.Units.Controllers
{
public class VehicleController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult CreateVehicle()
{
return View();
}
}
}
最佳答案
在匿名对象中,指定区域。
@Html.ActionLink("Create Vessel", "CreateVessel", "Vehicle", new { Area = "Units" })
关于visual-studio - 如何链接到 MVC4 中的区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7944948/