I have a controller called AuctionsController with a method
public ActionResult BidsByAuction(int auctionId, int page = 1)
When I navigate to /Auctions/BidsByAuction/38 I get the following error:
The parameters dictionary contains a null entry for parameter ‘auctionId’ of non-nullable type ‘System.Int32’ for method ‘System.Web.Mvc.ActionResult BidsByAuction(Int32)’ in ‘Extranet.Controllers.AuctionsController’. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
What is going wrong here?
Did you create a cutom route for your method that takes an AuctionID as a parameter? If not, then by default, the parameter is called “id”.
If you want auctionid, then you need to make a new route that sets the name to auctionid.
Not entirely sure that will fix your problem, since there may be a problem with the optional parameter as well, but fix this one and see what you get.