次のコントローラーの Global.asax でルートを設定しようとしていますが、常にHTTP エラー 404.0 - 見つかりません
AssetsController.cs
public class AssetsController : Controller
{
public ActionResult Index(string aDesc, string fDate)
{
ViewBag.DateFrom = fDate.ToString();
ViewBag.AssetDescription = aDesc.ToString();
return View();
}
}
Global.asax.cs
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapRoute("Assets", "Assets/{action}/{aDesc}/{fDate}",
new { controller = "Assets", action = "Index", aDesc = "", fDate = "" }
);
// Show a 404 error page for anything else.
routes.MapRoute("Error", "{*url}",
new { controller = "Error", action = "404" }
);
}
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
WebApiConfig.Register(GlobalConfiguration.Configuration);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AuthConfig.RegisterAuth();
}
}
次の URL を使用してビューにアクセスすると、すべて正常に動作し、期待どおりに動作します。
http://localhost/Assets/Index/?aDesc=090&fDate=20130701000000
しかし、次の URL を使用してビューにアクセスすると、404.0 エラー メッセージが表示されます (以下に示すエラー)。
http://localhost/Assets/Index/090/20130701000000
エラー: HTTP エラー 404.0 - 見つかりません お探しのリソースは削除されているか、名前が変更されているか、一時的に利用できません。
AppPool は .NET 4.0 統合モードに設定されています
HTTP リダイレクションと静的コンテンツは、一般的な HTTP 機能 (Windows 機能のオン/オフ) でチェックされます。