0

我有一个 MVC 4 Web api 服务层。我正在尝试使用此代码从我的 Web 应用程序调用服务层

HttpResponseMessage responsemsg = new HttpResponseMessage();
HttpClient client = new HttpClient();
            ServiceUrl = "http://localhost:51093";
client.BaseAddress = new Uri(ServiceUrl);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
ListParams LP = new ListParams();
LP.Add("param1", dtDate.SelectedDate);
LP.Add("Param2", AR.GetMaxAccountRefID().ToNonNullString());
foreach (KeyValuePair<string, object> item in LP)
            {
                param = param + item.Key + "=" + item.Value + "&";
            }
            try
            {
                responsemsg = client.GetAsync("/api/ProductAccount?" + param, HttpCompletionOption.ResponseContentRead).Result;
            }
if (responsemsg.IsSuccessStatusCode)
{
          // code
}

这工作正常..如果我要改变

ServiceUrl ="http://192.168.0.139:8080/"; //(Service Hosted path)

然后它没有调用并得到 404 错误。

请告诉我我在哪里缺少任何东西..

4

0 回答 0