DEV Community

Cover image for C++ web programming example

Posted on

C++ web programming example

The new version ( of Elanat will be ready soon.

In this version, you can create add-on with programming languages such as C, C++, Pascal, etc. (programming languages that generate machine code).

The use of C and C++ programming language on the web has many opponents; Of course, few experts also find it useful to use C and C++ programming languages on the web. For some applications, using C and C++ programming languages has great results; For example, creating a returnable code and decoding with hardware-based programming languages when the theft of server-side codes happens is time-consuming for hackers and a more suitable option for security systems than interpreted programming languages and It is virtual machines; Or in another example, the use of C and C++ programming languages in text analysis among several million books has a much higher performance than common web platforms and programming languages.

In the Elanat framework, new add-ons can be created using C and C++ programming languages.

For this, you just need to write the main function as follows:

#include <iostream>

using namespace std;

int main(int argc, char* argv[])
    cout << "Hello world!" << endl;

    cout << argv[1]; // QueryString
    cout << argv[2]; // FormData
    cout << argv[3]; // Session
    cout << argv[4]; // Cookie

    return 0;
Enter fullscreen mode Exit fullscreen mode

With a little ideation, you can have a View!
Create a cspx or ascx or chtml file side the executable file (exe in Windows).
When the form data does not exist (first request), read the values from the file with the programming language.
Don't be afraid to replace, in this type of programming language replace is done at the speed of light!

Receive information from formdata and write it on the page:

<form method="post" action="/page/cpp/main.exe">
  <label for="lbl_FirstName"><%=name=>:</label>
  <input id="txt_FirstName" name="txt_FirstName" type="text"><br>
  <label for="lbl_LastName"><%=name=>:</label>
  <input id="txt_LastName" name="txt_LastName" type="text"><br>
  <input name="btn_Submit" type="submit" value="Submit" onclick="el_AjaxPostBack(this)" class="el_button_input">
Enter fullscreen mode Exit fullscreen mode

Result in argv[2]; // FormData:

Because you are not using a framework with a listener for this type of programming language, the speed of accessing the published executable file is usually slow; But in the tests we did, we did not notice much difference. Meanwhile, this should not worry you because you can set the cache.

There are 8 types of add-on in Elanat. You can upload the executable file directly to page and plugin add-ons and see the result!.
If you are considering creating add-on of other types, or your add-on files are more than one executable or static file, you can check the links below and simply create an add-on.






Extra helper:

Editor template:

Note 1: In the previous versions of Elanat, which was based on the .NET standard, it was also possible to create an add-on using programming languages such as C, C++, Pascal, etc. But after migrating to .NET Core, a bug appeared in the version based on .NET Core (!

Note 2: Currently, you can create your own add-ons for Elanat with programming languages that generate machine code in the Windows operating system.

Note 3: You can also use a framework for C++; and create your add-ons in MVC.

Elanat is .NET Honor! More powerful than Dupal, more modern than WordPress, more structured than Microsoft SharePoint.

Elanat website:

Elanat repository link:

CodeBehind repository link:

Top comments (0)