Home > database >  How JavaScript Program Can Communicate With C# Console Application?
How JavaScript Program Can Communicate With C# Console Application?

Time:07-08

I'm trying to write a program that is composed of two parts. The logic part that I prefer to write in C# language because it's object oriented and more important it's the language witch I know the best among objective languages, and the graphic part witch I want to write it with Html, Css and JavaScript and again because they're the most familiar graphical languages witch I can use. Now my question is that how can I transfer data between a C# console app and a JavaScript browser app. Any help will be appreciated.

CodePudding user response:

If you're looking to have direct interop, blazor might be what you're looking for.

https://docs.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/call-javascript-from-dotnet?view=aspnetcore-6.0

CodePudding user response:

What you describe should be a full stack application to be honest

With ASP.NET you create your C# backend, setup controllers which handle the interaction between backend code and the front end, and then on the front end you can utilize both Razor markup for HTML templating alongside standard Javascript.

With Blazor web apps, you can take it a step further and have your backend code compile to web assembly and execute directly on the client engine, but it also integrates javascript interop as well. Just be mindful about whether you want a client side or server side Blazor app, as each do things a certain way and are meant for different use cases

What you describe though, sounds more precisely like you want a seperate javascript app, which should be in communication with an ASP.NET Web API. This way you create your backend and api endpoints, which the javascript app can then make requests against. You can start your research for that with MS's tutorial here

The dotNet command line tools can generate solutions for all of these, an ASP.NET fullstack web app, ASP.NET Web API solution, as well as the various blazor app options. And of course, the standard IDE's like Visual Studio and Rider can create these solutions as well

CodePudding user response:

You can write everything in js only and use node js for running you project instead of using c#

  • Related