-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