-2
如何在将图像从控制台应用程序传输到服务器api后,如何在主控制器的索引上显示图像?在用api传输图像后在mvc网站上显示图像
如何在将图像从控制台应用程序传输到服务器api后,如何在主控制器的索引上显示图像?在用api传输图像后在mvc网站上显示图像
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;
namespace Fotobox_Client
{
public class Api_Client_Server
{
public async Task Put(byte[] byteArray)
{
using (HttpClient client = CreateClient())
{
HttpResponseMessage response = await client.PutAsJsonAsync("Image", byteArray);
if (!response.IsSuccessStatusCode)
{
throw new ArgumentException(response.ReasonPhrase);
}
}
}
public HttpClient CreateClient()
{
HttpClient client = new HttpClient();
client.BaseAddress = new Uri("http://localhost:61869/api/");
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return client;
}
}
}
你能分享你试过的任何代码吗?如果您可以提供您正在尝试的代码的示例,而不是要求从整个布料创建代码,这会更有帮助。请参阅https://stackoverflow.com/help/how-to-ask。 – PaSTE