I have an action that takes the userId parameter:
~ / Users / show? User ID = 1234
Everything works just fine unless the provided userId is int or missing.
Then it throws this exception:
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 which the user is redirected to the error page.
How to set up a route so that the action fails at all, and instead it throws 404?
source share