I am working on a webpage where I have to filter results using value from the select menu's selected option when the user clicks on filter button by sending a get parameter to the index method.
2 Answers
refIdis never passed into theIndexmethod
In your code, we can find that you specify asp-for="@Model.FirstOrDefault().RefereeId" for your <select> tag, if you check the source code of this dropdown in browser, you would find name attribute value is RefereeId (not refId) as below. So it would pass something like RefereeId=168 through querystring to your action, and parameter refId of your action would always be 0, which cause the issue.
To fix it, you can try to rename your action parameter to RefereeId, like below.
public async Task<IActionResult> Index(int RefereeId)
{
//code logic here
Or modify view page code to set name of <select> tag with "refId".
<select name="refId" asp-items="@ViewBag.PersonId"></select>
