ASP.NET API接口获取请求头中的数据和获取form-data中的图片

//获取请求头的Uid
IEnumerable<string> Uid;
Request.Headers.TryGetValues("uid", out Uid);
List<string> list = new List<string>();
list = Uid.ToList();

User user = ubll.Search(Convert.ToInt32(list[0]));

//获取图片
HttpPostedFile file = HttpContext.Current.Request.Files["HeadImage"];
string  nickname = HttpContext.Current.Request["Name"];
string name = file.FileName;
string path = HttpContext.Current.Server.MapPath("~/image/");
string jpname = Path.GetExtension(name);
file.SaveAs(path + file.FileName);

猜你喜欢

转载自blog.csdn.net/qq_37240051/article/details/80741874