【发布时间】:2012-03-02 11:42:21
【问题描述】:
我有一个带有 userId 参数的操作:
~/Users/Show?userId=1234
一切正常,除非提供的 userId 不是 int 或丢失。
然后它抛出这个异常:
Message: The parameters dictionary contains a null entry for parameter 'userId' of
non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Show(Int32,
System.Nullable`1[System.Boolean], System.String)' in 'S4U.Web.Mvc.Controllers.ProfileController'. An optional parameter must be a reference type,
a nullable type, or be declared as an optional parameter.
Parameter name: parameters
..之后用户被重定向到错误页面。
如何配置路由以使该操作根本不被命中而引发 404?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-3 asp.net-mvc-routing