Page 1 of 1

how to upload files?

Posted: Mon Nov 20, 2017 4:21 pm
by maoming
Hi,
cshtml5 how to upload files? Is there such an example? Thank you!

Re: how to upload files?

Posted: Wed Nov 22, 2017 6:12 am
by JS-Support @Userware
Hi and welcome to the forums.

Uploading a file with CSHTML5 works the same as in Silverlight. Most of the required work in done server-side. For example, if your server is based on asp.net, you can create a IHttpHandler that receives the file. On the client side, all you have to do is call the method "WebClient.UploadString(Uri address, string data)".

For a complete tutorial, please read the following page:
http://www.c-sharpcorner.com/uploadfile/nipuntomar/file-upload-in-silverlight/

The only difference in CSHTML5 compared to the tutorial above is that you need to replace "WebClient.OpenWrite" with "WebClient.UploadString" because "WebClient.OpenWrite" is not yet supported in CSHTML5 at the time of writing.

If you follow the tutorial and run into any issues, please feel free to post a simple VS project that reproduces the issue and we will look into your issues.

Thanks.
Regards,
JS-Support