Custom user action in the context menu of the modern list

I am developing a custom user action to be used in modern list / library views. The problem is that, since we can not use JavaScript in the custom action of the context menu, how should I form a valid URL? Now I have a URL like:{StandardTokens{&Action= test & ListId = {ListId} & ItemId = {ItemId} & Source = {Source}

I want to encode the previous URL in C # but in such a way that dynamic parameters like it {ListId} jobs. It is easy to do this in JS using escape but it does not work without javascript. I've already tried HttpUtility.JavaScriptStringEncode and few other coding mechanisms, but all are failing in one way or another.

URL that works with JS (this works as a ribbon but in the context menu, this is not allowed):

string UrlAction = "javascript: window.location = & # 39;" + BaseUrl + "& redirect_uri = & # 39; + escape (& # 39;" + remoteWebUrl + "/Pages/Default.aspx?{&ItikIlPme & Source = {Source} & # 39;)";