Search code examples
javascriptc#asp.net-mvcarraybuffer

preparing and sending binary data to javascript for webgl


I have a very long list of points (lat/long) in my C# program and I need to pass it to my webgl code. I have done it before using json but I thought I could reduce the bandwidth if I sent the data in binary format. Based on my research, on the client side I should use XMLHttpRequest with arraybuffer as response type. I just do not know what to do on the server side. I mean how to prepare the binary data in C# that could be interpreted as arraybuffer in javascript. I am new to web programming, so if I am not clear on any part, please let me know.


Solution

  • I am not an expert, but I found this solution to work: On the server side, convert the array of numbers to a byte array and then send the byte array to javascript as a binary file (Set the Mime type to "application/octet-stream")