I have an API end point that takes a query string parameter but the value returned is always null even when a value is passed.
This is my method in Blazor web app,
public async Employee GetEmployee(EmployeeDetails details)
{
var qString = string.Empty;
if (details != null)
{
if(details.EmployeeId != null)
{
qString += "empId=" + details.EmployeeId;
var employee = await _httpClient.GetAsync($"api/EmployeeData/GetData?{qString}");
return employee;
}
}
}
I have the following endpoint in the employee data controller within the api,
public async Task<ActionResult<Employee>> GetData([FromQuery] string? Id)
{
///The value of query string Id is always null here.
}
Am I missing something? Could someone point me in the correct direction please?
Thanks in Advance