摘要: public Task PostFormData(){ // Check if the request contains multipart/form-data. if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } string root = HttpContext.Current.Server.MapPath("~/App_Data"); var prov... 阅读全文
posted @ 2013-09-04 17:30 火腿骑士 阅读(253) 评论(0) 推荐(0)
摘要: using System.Net;using System.Net.Http;using System.Web;using System.Web.Http;namespace FileUploadTest.Controllers{public class FileUploadController : ApiController{ public async Task Post() { if (Request.Content.IsMimeMultipartContent()) { var path = HttpContext.Curre... 阅读全文
posted @ 2013-09-04 17:21 火腿骑士 阅读(242) 评论(0) 推荐(0)
摘要: 演示如何通过 web api 上传文件WebApiWebFormHost/UploadFileController.cs/* * 通过 web api 上传文件 */using System;using System.Collections.Generic;using System.Linq;using System.Net;using System.Net.Http;using System.Threading.Tasks;using System.Web.Http;namespace MVC40.Controllers{ public class UploadFileControll... 阅读全文
posted @ 2013-09-04 17:11 火腿骑士 阅读(739) 评论(1) 推荐(0)
摘要: IOS5开发-http get/post调用mvc4 webapi互操作(图片上传)目前最流行的跨平台交互是采用http协议通过JSON对象进行互操作。这种方式最简单,也很高效。webservice+xml的方式似乎已经过时。下面是我做的一个例子webapi的代码public IEnumerable GetAllProducts() { Console.WriteLine(DateTime.Now.ToLongTimeString() + " : receive request."); return new List ... 阅读全文
posted @ 2013-09-04 17:06 火腿骑士 阅读(396) 评论(0) 推荐(0)