に名前を持ってしようとしている:ASP.NET MVCルーティング - 私は現在、次のルートを持っているURL
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.gif/{*pathInfo}");
MvcRoute.MappUrl("{controller}/{action}/{ID}")
.WithDefaults(new { controller = "home", action = "index", ID = 0 })
.WithConstraints(new { controller = "..." })
.AddWithName("default", routes)
.RouteHandler = new MvcRouteHandler();
MvcRoute.MappUrl("{title}/{ID}")
.WithDefaults(new { controller = "special", action = "Index" })
.AddWithName("view", routes)
.RouteHandler = new MvcRouteHandler();
SpecialControllerは方法があります:私はhttp://hostname/test/5
に私のブラウザをポイントするたびに、public ActionResult Index(int ID)
を私は次のエラーを取得する:
The parameters dictionary contains a null entry for parameter 'ID' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Index(Int32)' in 'SpecialController'. To make a parameter optional its type should be either a reference type or a Nullable type.
Parameter name: parameters
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
それはなぜですか?私はmvccontribルートデバッガを使用して、ルートが期待通りにアクセス可能であるようです。
同様に、同じ例外がスローされます)。 – Yannis
MappUrl拡張メソッドのコードを投稿できますか? – womp
それは私のコードではありません。それはmvccontribの一部です。私はソースを利用できません。 – Yannis