0

RouteConfig,cs ファイルに次のルートがあります。

routes.MapRoute(
    name: "SectionHomePage",
    url: "{SectionType}/{SectionID}",
    constraints: new { SectionType = @"(Books|Cinema|Collections|Games)" },
    defaults: new { controller = "SectionHomePageController" }
    );

可能であれば、actionパラメーターの名前を変更するSectionTypeか、何らかの方法でパラメーターに割り当てるSectionTypeことactionです。(名前を変更できることはわかっていますが、読みやすくするために名前SectionTypeactionそのままにしておきたいです)。

コントローラ:

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」という名前の項目が含まれている必要があります。

4

2 に答える 2