Receiving raw bytes from a web request

bh_eng
Posts: 1
Joined: Fri Feb 03, 2017 12:49 pm

Receiving raw bytes from a web request

Postby bh_eng » Fri Feb 03, 2017 1:16 pm

Hello,

I'm dealing with a web API that returns an array of raw bytes.

Is there any way to do this through the existing C# functionality?
For instance, your standard way of querying a webserver within an application,
WebClient, has this ability in .NET's library, via UploadData and DownloadData and their variants.
That functionality looks like it's not implemented yet in the cshtml libraries, where the WebClient only has the ability to deal with strings.

Is there a way to access a less abstracted web client like HttpWebRequest?

If it's not possible purely through C#, is there a way to share variables through C# and JS?
I'm going to try doing this by getting the data in javascript, and passing it to a C# function that is expecting an object, then casting that to a byte[].
Even if this works, it just feels super hacky.

I just want to know if someone is aware of a more elegant solution to this.

JS-Support
Site Admin
Posts: 684
Joined: Tue Apr 08, 2014 3:42 pm

Re: Receiving raw bytes from a web request

Postby JS-Support » Thu Feb 09, 2017 5:29 am

Hi,

The ability to pass byte arrays between the client and the server has just been added to the Beta 10.8, but only for SOAP web services (not WebAPI).

WebClient.UploadData and DownloadData are indeed not yet supported. They are on the roadmap for 2017-2018 (note that it is possible to get it in just a few weeks by funding the development of the feature, please contact us for a quote if interested).

A workaround is indeed to use a JavaScript call. Yes you can pass variables between C# and JS. Please refer to the following page for documentation:
http://cshtml5.com/links/how-to-call-javascript.aspx

You may also be interested by the open-source jquery.ajax extension for CSHTML5, available at:
http://forums.cshtml5.com/viewtopic.php?f=7&t=7900

Thanks.
Regards,
JS-Support


Return to “General Discussion and Other”

Who is online

Users browsing this forum: No registered users and 1 guest

 

 

cron