How to execute c # codices in the browser?

1

Is there any way to integrate HTML and C #? Or how to make a Debug for C #?

So, this question I'm asking other people, who know program C # apps, who are venturing into the Web world end up building a site in C # in place of JS, PHP or others.

As I mentioned in the second question, a C # debug, for online publishers, more to verify that the code is correct and not to any bug, without the need to execute it (as entirely a program itself).

    
asked by anonymous 05.04.2016 / 14:39

2 answers

1

I'm not going to tell you that it's impossible because I've seen people making even a Linux kernel (OS) running through javascript "embbedado" in the Browser.

Linux Emulator with Javascript

But one thing is for sure, any solution that you want to do right in the browser will not be able to escape doing it using Javascript as an intermediate language running as C # interpreter / compiler, which is cool but super complex. / p>

Some solutions usually take a snippet of code, upload it to the server, run it there, and return the result in HTML.

There are many websites today that simulate the result of a C # code that you can use as a teaching platform eg:

link

Hugs!

    
06.04.2016 / 00:41
0

It is not possible to execute C # code directly in the client browser because the codes are executed on the server and for the client only pure HTML is returned.

The same concept applies to classic ASP pages, PHP, ASP.Net, etc.

What you can do is through jQuery to call a C # statement on the server, this statement will process and make a return of HTML

Aside from this approach being more performative, you have a gain with security because you imagine writing the direct connection string in the client's browser.

Sample postback code with jQuery:

$.ajax({
    url: "@Url.Action("DeleteMessage", "Home")",
    type: "POST",
    data: { messageid: GetCurrentMessageID(), mailbox: GetCurrentMailbox() },
    dataType: 'json',
    cache: false,
    success: function (data) {
         //Sucesso, faça algo
    },
    error: function (jqXHR, exception) {
         //Erro
    }
});

I think that way you can have a north, this code I use in an application with ASP.Net MVC, the page calls the code in postback and returns to the client only what I want (A message, a grid , etc.)

I hope I have helped!

    
06.04.2016 / 00:26