I am starting a new project that will display a complex graph using an HTML5 canvas.
We currently have an implementation of Windows Forms, and we want to transfer it to the Internet. Thus, the layout, drawing objects, and all drawing metadata are generated in C #. We only need to implement the drawing, and we will use the HTML5 canvas.
On the server side there will be ASP MVC. He will calculate the drawing model and send it to the client. The client will then use the canvas to represent the data.
The problem is that the drawing model can sometimes be huge. Possibly 10Mb-50Mb metadata. What is the best way to send all drawing data from the server to the client?
Use the model for the script on the page that creates the drawing objects in JavaScript
This will be the standard way. I will generate a model with drawing objects in C #, and then I will convert these objects to JavaScript.
- PROS: easy to implement
- CONS: the page will be heavy.
Return JsonResult from the controller returning drawing data
I could get it, for example, using jQuery. This option failed because I reached the maxJsonLength property. I know that it can be changed in web.config, but it seems like this is not a good idea. 3.
- PROS: Simple implementation, can use ajax to load drawing objects from the server and report progress to the user.
- CONS: It does not seem like a good idea to change the maxJsonLength property in Web.config.
Creating a temp script file with drawing data on the server and including it on the client page
The server will generate drawing data in a JS script file. Then the server will include this page as JavaScript on the client page, so the drawing data will be loaded in the client. This load can also be accomplished with ajax.
- PROS: This is like downloading a file, if it is very large, it will not be a problem.
- CONS: harder to implement. We need to manage temporary files, and we need to know when the file was transferred, and then delete it.
Another alternative
Any other options would be welcome , as I am not an expert in HTML programming.
source share