RouteConfig,cs ファイルに次のルートがあります。
routes.MapRoute(
name: "SectionHomePage",
url: "{SectionType}/{SectionID}",
constraints: new { SectionType = @"(Books|Cinema|Collections|Games)" },
defaults: new { controller = "SectionHomePageController" }
);
可能であれば、action
パラメーターの名前を変更するSectionType
か、何らかの方法でパラメーターに割り当てるSectionType
ことaction
です。(名前を変更できることはわかっていますが、読みやすくするために名前SectionType
をaction
そのままにしておきたいです)。
コントローラ:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace FFInfo.WebUI.Controllers
{
public class SectionHomePageController : Controller
{
// GET: /SectionHomePage/
public ActionResult Games()
{
//ViewBag.Head = RouteData.Values["id"];
return View();
}
}
}
エラー:
RouteData には、空でない文字列値を持つ「action」という名前の項目が含まれている必要があります。