Asp.net mvc 4 MVC Web API POST请求不是从客户端应用程序发出的,而是从chrome Postman扩展发出的

Asp.net mvc 4 MVC Web API POST请求不是从客户端应用程序发出的,而是从chrome Postman扩展发出的,asp.net-mvc-4,asp.net-web-api,wcf-web-api,asp.net-web-api-routing,Asp.net Mvc 4,Asp.net Web Api,Wcf Web Api,Asp.net Web Api Routing,我有一个带有控制器的WebAPI服务,如下所示 RoutePrefix("api/Product")] public class ProductController : ApiController { [HttpPost] [POST("InsertProduct")] public HttpResponseMessage InsertProduct(ProductDetail product) { //logic } [Http

我有一个带有控制器的WebAPI服务,如下所示

RoutePrefix("api/Product")]
public class ProductController : ApiController
{
    [HttpPost]
    [POST("InsertProduct")]
    public HttpResponseMessage InsertProduct(ProductDetail product)
    {
        //logic
    }

    [HttpGet]
    [GET("Item/{itemId}/{itemtypeid}")]
    public List<ProductDetail> GetProduct(int itemId, long itemtypeid)
    {
    //logic
        return response;
    }
}
RoutePrefix(“api/产品”)]
公共类ProductController:ApicController
{
[HttpPost]
[发布(“插入产品”)]
公共HttpResponseMessage InsertProduct(产品详细信息产品)
{
//逻辑
}
[HttpGet]
[获取(“Item/{itemId}/{itemtypeid}”)]
公共列表GetProduct(int itemId、long itemtypeid)
{
//逻辑
返回响应;
}
}
在这里,GET请求可以从邮差工具(chrome Rest服务测试仪url)和客户端(请参阅下文)执行。POST请求可以与Postman工具配合使用。但是当我从客户端尝试相同的代码时,我得到了以下错误 “状态代码:404,原因短语:'未找到'

客户端代码:

HttpClient client = new HttpClient();
        client.BaseAddress = new Uri("http://localhost/ProductService/");
        client.DefaultRequestHeaders.Accept.Add(
            new MediaTypeWithQualityHeaderValue("application/json"));

        string serializedContent = JsonConvert.SerializeObject(new ProductDetail());
        StringContent stringContent = new System.Net.Http.StringContent(serializedContent, Encoding.UTF8, "application/json");

        HttpResponseMessage response = client.PostAsJsonAsync<ProductDetail>("api/Product/InsertProduct", new ProductDetail()).Result;
HttpClient=newhttpclient();
client.BaseAddress=新Uri(“http://localhost/ProductService/");
client.DefaultRequestHeaders.Accept.Add(
新的MediaTypeWithQualityHeaderValue(“应用程序/json”);
string serializedContent=JsonConvert.SerializeObject(新产品详细信息());
StringContent-StringContent=new System.Net.Http.StringContent(serializedContent,Encoding.UTF8,“application/json”);
HttpResponseMessage response=client.postsjsonasync(“api/Product/InsertProduct”,new ProductDetail()).Result;
相同的请求如何从任何外部工具中工作,而不是从httpclient中工作

请帮我做这个