I am developing a user custom action to be used in modern list/library views. The issue is, as we cannot use JavaScript in context menu custom action, how should I form a valid URL. Now I have a URL like:


I want to encode the above URL in C# but in such a way that dynamic params like {ListId} works. It is easy to do this in JS by using escape but not working without javascript. I have already tried HttpUtility.JavaScriptStringEncode and few other encoding mechanisms but all are failing one way or other.

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

string UrlAction = "javascript:window.location='" + BaseUrl + "&redirect_uri=' + escape('" + remoteWebUrl + "/Pages/Default.aspx?{StandardTokens}&Action=test&ListId={ListId}&ItemId={ItemId}&Source={Source}')";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.