1

Is it possible to sandbox a JavaScript function in C# code, execute it by passing in an argument such as an array, and return a result. No web browser involved here, this is not an Ajax or 'registerstartupscript' type of question.

1

2 Answers 2

3

From my own experience, for simple things Jurassic works like a charm and it's a JavaScript that can be used to run-time compile JavaScript and call functions, variables or whatever.

For example, taken from their own doc pages:

var engine = new Jurassic.ScriptEngine();
Console.WriteLine(engine.Evaluate("5 * 10 + 2"));

There're other options which involves embedding a full JavaScript engine, but AFAIK and reading your question's requirement, it seems like Jurassic should work in your scenario and you get the advantage of using a managed JavaScript compiler written in C# so there's no other dependency than the BCL from .NET and Jurassic itself.

Sign up to request clarification or add additional context in comments.

2 Comments

@MatíasFidemraizer, do you know if nodeService in dotnetcore can also run code in a sandbox?
@JavaadPatel I don't know that, sorry :(
1

Yes, you can!

JavaScript.NET is a .NET port of Google's V8 engine.

Another one I quite like is called Jurassic and it's available on nuget.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.