visual-studio - 如何链接到 MVC4 中的区域

标签 visual-studio asp.net-mvc-4

我不确定 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/

相关文章:

c# - CaSTLe Windsor激活错误IController,key "home"

asp.net-mvc-4 - 将 View 标记为嵌入资源

c# - 找不到动脉 SignalR/ping MVC 4

c# - Visual Studio 丢失/移动了我的断点

C# 无法在 asp.net 中读取 XML 文件

c# - 一次编译为两个 .NET 框架

javascript - 如何在一个 html 标签上调用多个 onkeyup 事件

c# - MVC5 项目中 exe 文件的用途是什么?

xml - 如何在 Visual Studio 中打开 XML 文档属性窗口?

visual-studio - 如何让 Visual Studio 2010 自动创建可折叠区域