composite key http

asgar ali 0 Reputation points
2025-07-02T07:19:41.8266667+00:00

@Html.ActionLink("Edit", "Edit", new { item.monthr,item.tennant }) getting an error . monthr and tennant are the keys.

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Raymond Huynh (WICLOUD CORPORATION) 620 Reputation points Microsoft External Staff
    2025-07-07T07:14:54.19+00:00

    Hi asgar!

    It looks like you’re trying to create an Edit link using @Html.ActionLink and you have a composite key with monthr and tennant. In your code:

    @Html.ActionLink("Edit", "Edit", new { item.monthr, item.tennant })
    

    The issue is probably with how the parameters are being passed. In C#, when you use an anonymous object, you need to specify the property names, like this:

    @Html.ActionLink("Edit", "Edit", new { monthr = item.monthr, tennant = item.tennant })
    

    This way, both monthr and tennant will be included in the URL and sent to your Edit action. Also, make sure your controller’s Edit action is set up to accept both parameters:

    public IActionResult Edit(int monthr, int tennant)
    {
        // Your code here
    }
    

    If this isn’t the error you’re seeing, could you please share the exact error message? That will help me figure out what’s going wrong and give you a more specific solution.

    Hope this helps!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.