デフォルトのプリセット プロジェクトを使用して、独自のアプリケーションを構築しています。
独自のコントローラーMyController
と新しいビュー ディレクトリMy
を追加しましたindex.cshtml
。
これはコントローラーコードです:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebProject1.Controllers
{
public class MyController: Controller
{
//
// GET: /My/
public ActionResult Index()
{
return View();
}
}
}
これが私のものRouteConfig.cs
です:
// ...
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "My", action = "Index", id = UrlParameter.Optional }
);
}
}
// ...
ただし、デバッグを開始し/My/
て 404 エラーに移動すると、次の行に沿ったメッセージThe resource or one of its dependencies cannot be found.
が表示されます。
コントローラーを機能させるにはどうすればよいですか?