Passing parameter to controller action from a Html.ActionLink RRS feed

  • Question

  • User899763586 posted


    I try to pass parametes with html helper @html.actionlink but it pass null.

    The @html.actionlink:

    <li>@Html.ActionLink("רישום מנהל עירוני", "RegisterStuff", "AdminAccount", new { area = "Admin" }, new { orgID = @SessionManager.User.OrganizationID, roleID = 3})</li>

    The controller:

    // GET: /Account/Register
    public ActionResult RegisterStuff(int orgID , int roleID)
    return View();

    The error message:

    System.ArgumentException: The parameters dictionary contains a null entry for parameter 'orgID' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult RegisterStuff(Int32, Int32)' in 'SummerSchool.WEB.Areas.Admin.Controllers.AdminAccountController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional paramete

    Sunday, November 11, 2018 6:20 PM

All replies

  • User-474980206 posted

    you are setting the anchors html attributes to orgid ad rollid, not route values. try:

    <li>@Html.ActionLink("רישום מנהל עירוני", "RegisterStuff", "AdminAccount", new { area = "Admin", orgID = SessionManager.User.OrganizationID, roleID = 3}, new {})</li>

    Sunday, November 11, 2018 8:08 PM
  • User899763586 posted

    Hi bruce

    Thanks, it works



    Monday, November 12, 2018 8:07 PM