Action method expected parameter named Id and nothing otherwise
- by codingbiz
The Error
The parameters dictionary contains a null entry for parameter 'UserId'
of non-nullable type 'System.Int64' for method
'System.Web.Mvc.ActionResult Predict(Int64)' in
'sportingbiz.Controllers.PredictionController'. An optional parameter
must be a reference type, a nullable type, or be declared as an
optional parameter. Parameter name: parameters
This does not work. Throws the error mentioned above
http://mysite/User/Profile/15
This works
http://mysite/User/Profile/?UserID=15
The Controller Action
public ActionResult Profile(long UserID)
{
}
When I changed the parameter name to Id it works. I think it's because Id was specified in the route collection (Global.asax). Is it possible to tell MVC that UserId should map to Id without changing it in the Global.asax