作者clsshan2010 (livingroom)
看板C_Sharp
标题[问题] Windows Service如何call Web程式
时间Fri Apr 29 08:47:13 2016
如题
最近要写一套系统,是由client端 上传档案到 Server端进行处理。
client的是定时每几分钟就要启动的,公司要求写成Windows service
Server端是.NET MVC的Web程式,没有页面,只提供cotroller 呼叫。
因为小弟是.net新手,本身是JAVA出身,想请问大大有没有关键字或是
相关资料可以供小弟参考,先谢谢各位大大了。
//後续问题................
感谢大大提供关键字,目前小弟有找着官网范例及文件初步完成了web api
遇到一些问题还烦请各位大大帮我看一下是否哪边有出错
webapi的程式:
[HttpPost]
public string TransferData([FromBody] byte[] fileByte){
//code
}
client端的部分(Windows Form):
HttpClient client = new HttpClient();
ByteArrayContent content = new ByteArrayContent(File.ReadAllBytes(fileName));
await client.PostAsync("
http://localhost:33867/POIC/api/controller/
TransferDate", content);
执行的时候webapi的fileByte部分取出来都是null
如果型态改成字串,且client部分也传字串是OK的
请问大大如果想要实作一个档案传到webapi应该怎麽写比较好?
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 202.173.43.216
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/C_Sharp/M.1461890836.A.B0A.html
1F:推 WindOfNet: web api~ 04/29 09:23
※ 编辑: clsshan2010 (202.173.43.216), 04/29/2016 19:32:36
※ 编辑: clsshan2010 (202.173.43.216), 04/29/2016 19:32:59