I created a page like this in one of my modules – /OrchardLocal/Module1/Controller1/Action1. It takes an id parameter.
The page works if the id is passed like this – /OrchardLocal/Module1/Controller1/Action1/7
But I get an error if I pass the id in querystring – /OrchardLocal/Module1/Controller1/Action1?id=7
“The parameters dictionary contains a null entry for parameter ‘id’ of non-nullable type ‘System.Int32′”
I don’t have to use querystring. But I would like to know why it is not working and how can I make it work with querystring.
Thanks
[EDIT]
Here is the action method.
public ActionResult Action1(int id)
{
...
}
This is what I have in Routes.cs.
new RouteDescriptor {
Priority = 6,
Route = new Route("Action1/{id}",
new RouteValueDictionary{{"area", "Module1"},{"controller","Controller1"},{"action","Action1"}},
new RouteValueDictionary(),
new RouteValueDictionary{{"area", "Module1"}},
new MvcRouteHandler())
}
This is a matter of routing, not Orchard. This should work if you set id param as optional:
Note: with priority 6 I can’t repro your error. It could be because you are on an earlier version of Orchard. I’m on 1.4. With Priority = 100 I can repro your error, and then the above change fixes it.