The problem and workaround is described in this article. (There is a little bug, because GetModel
should be named GetCustomerId
)
Passing parameters is not supported, exactly as the Exception says.
You can wait for ASP.NET Core 3.1, where the ability to pass parameters will be restored.
I have implemented the solution from the first article for parameter OperationId
like this - razor component's code:
using Microsoft.JSInterop;
[Inject]
protected IJSRuntime jrt { get; set; }
protected async override Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
try
{
var oid = await jrt.InvokeAsync<string>("GetOperationId");
int opid;
if (int.TryParse(oid, out opid))
OperationId = opid;
}
catch (Exception ex)
{
ls?.LogException(ex, "Sortiment.OnAfterRenderAsync");
}
//This code was moved from OnInitializedAsync which executes without parameter value
if (OperationId.HasValue)
sortiment = await ProductService.GetSortimentAsync(null, OperationId, Odpady);
else
productFilter = await ProductService.GetProductFilterAsync();
StateHasChanged(); //Necessary, because the StateHasChanged does not fire automatically here
}
}
and added this to the hosting Razor page:
@section Header
{
<script>
function GetOperationId() {
return "@Model.OperationId";
}
</script>
}
This workaround works only for RenderMode.Server
.