I have a javascript code (business logic) runs on client side, i want the same logic to execute from windows service (C# code), instead of re-writing those complex javascript code to C#, is there any way to execute it from C# class itself. Because i want to run this code inside windows service
Asked
Active
Viewed 215 times
0
-
Do you want to simulate a web browser and run your JavaScript on it? If yes, the [**Selenium**](http://stackoverflow.com/documentation/selenium-webdriver/topics) framework might be a good choice – Jakub Loksa Aug 04 '16 at 16:58
-
No, for example, in javascript i have a different functions which takes the Json data and does lots of business validation and extracts result out of it and dumps into database using REST service, i need the same logig to extract result from json input to run on windows service(scheduled one). Moving this javascript logic to C# will take lots of time and effort for testing. so i'm thinking any is there quick way without re-writing those code in C#, just execute and store the result in db – Mathiyazhagan Aug 04 '16 at 17:05
-
https://rushfrisby.com/which-net-javascript-engine-is-the-fastest/ or http://stackoverflow.com/questions/172753/embedding-javascript-engine-into-net may be a starting point... Note that if your JavaScript was not written to run without browser rewriting code in C# may be faster option... – Alexei Levenkov Aug 04 '16 at 17:13
1 Answers
2
In theory, yes, you can. MicroSoft has released the JS engine behind the Edge browser - Chakra. You can find it on GitHub.

Bozhidar Stoyneff
- 3,576
- 1
- 18
- 28
-
@AlexeiLevenkov: "write one from scratch" - what do you mean? It is already written and you can execute scripts directly... – Bozhidar Stoyneff Aug 04 '16 at 17:40