New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I do this with client-side only programming with Balzor #5665

zydjohnHotmail opened this Issue Dec 5, 2018 · 2 comments


None yet
3 participants

zydjohnHotmail commented Dec 5, 2018

I want to know if I can do this with client-side only programming with Blazor.
I need to monitor a remote web site"", (a fake domain name), which has a lot of JavaScript scripts, one of them is like this one:

<!doctype html>

<title>Simple Random Generator</title> <script type="text/javascript"> document.getElementById("CurrentNumber").innerHTML = Math.random().toString(); </script>

The web site will from time to time run the JavaScript to show a random number on its web site, the time, when the script run is totally random.
I want to write a C# project using Blazor client-side to monitor the web site and get the random numbers generated by the JavaScript.
As most of documents I read about Blazor are talking about using Blazor to build a web site using .cshtml as file name extension.
But here, what I want to do, the server side is totally out of my control, I can only do some client-side job.
I want to know if Blazor on client-side can do this or not? Like visit a remote web site, and render the HTML contents, and listen to the DOM events, i.e. DOMContentLoaded, etc.
If it is possible, it is better to show me some sample code here for my current question: to get the dynamic contents generated by JavaScript.
I am using VS2017 Version 15.9.3 and latest Blazor version on Windows 10.
If Blazor can't do this at the moment, please also advice if Blazor could do this in the future. I don't think many people need to build a Web Server using C#, they could build a Web Server using JavaScript for the dynamic contents, which is standard way nowadays. But I believe, many people could like to use .NET based browser to visit web sites built by other people.


This comment has been minimized.

Damitrix commented Dec 7, 2018

The "correct" thing to go about doing this is probably straight up replicating the Javascript that the Website is running in your Blazor Application.
Other than that, you can always use html IFrames, to display a whole Website inside of your Application.


This comment has been minimized.

zydjohnHotmail commented Dec 7, 2018

As my knowledge for Blazor is limited, I don't quite understand your meaning.
Can you provide some code example? By the way, replicating the JavaScript is, in many cases, not possible. In my case, the number JavaScript scripts on that web site is 100+, and have no idea which one is necessary, but I know I care about the dynamic content generated by only one JavaScript.
Please advice by showing some code for your suggestion.

@aspnet-hello aspnet-hello transferred this issue from aspnet/Blazor Dec 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment