I'm trying to call an action in my controller:
using this url:
http://localhost:5345/ManageTest/Details/5
[Authorize]
public class ManageTestController : Controller
{
public ActionResult Details(int testId)
{
The parameters dictionary contains a null entry for parameter 'testId' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Details(Int32)' in 'MAMAdmin.Controllers.ManageTestController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters
That looks like you're trying to map to the default route, which is:
RouteTable.Routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
To do that, change your parameter name in your ActionResult
to be id
:
public ActionResult Details(int id)
Otherwise you'd have to use the URL:
http://localhost:5345/ManageTest/Details?testId=5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With