我和行動,這需要userid參數:ASP.net MVC路線的參數異常
〜/用戶/顯示用戶id = 1234
一切正常,除非提供的用戶id不是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
..after用戶被重定向到錯誤頁面。
我該如何配置路由,以便根本不會觸發該操作,而是會拋出404錯誤?