Write information in the browser console via the . NET

Asked

Viewed 711 times

0

I need to demonstrate information on browser the classic console.log Javascript, only that I would like to do this on browser with . Net and not on output Visual Studio because I believe that Azure is preventing the execution of some methods of an application and as a quick solution I thought to insert within the methods. I don’t know if it’s possible, or if it’s the best option.

MVC4 application, I use Firebug on browser.

  • Take a look at the documentation of troubleshooting in webapps. It has to activate several logs, trackings. It has as you debug remotely.

  • What @Thiagolunardi said might be a good one. But a nut solution could be using Signalr, it will allow you to send real-time messages to the customer that can be handled the way you want through Javascript, then you display them on the console.

  • Did the answer solve the problem? Do you think you can accept one of them? See [tour] how to do this. You’d be helping the community by identifying the best solution. You can only accept one of them, but you can vote for anything on the entire site.

1 answer

2

Not possible this way. What runs in the browser is independent of what runs on the server. There is no way the server (in this case ASP.NET) can directly instruct what the browser should run.

The most you can do is generate a page in C# (through a view in MVC) that has a Javascript code to be executed by the browser (preferably only the JS call exists on this page and the JS code itself is in a separate file already defined and saved in a static way). I mean, what matters to do this is the part that will be inside the <script></script>.

This page will obviously be sent to the HTTP server which you will later send to the browser. The browser that will run the JS code and do what you want.

  • It’s wrong what I said?

  • 1

    I also did not understand why down vote.

  • Maybe the answer is weak, but it is not reason to p/ negative. Especially considering that the question is not something that can be answered very differently from this. If you have a better solution than this, just the person post, I will positivize and learn.

  • Exactly, there is no exact answer to that question.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.