在一个asp.net mvc应用程序中,我有一个方法将JsonResult返回给视图。它在我的本地机器上完美工作,但是当应用程序部署在虚拟主机服务器上时,当我尝试通过点击视图链接来获取这些数据时,我在Firebug中找到了404 Not Found。有没有人知道这可能发生的可能原因?我的代码的只言片语我如何生成路径低于:Json 404未找到
private void get_info()
{
var serviceUri = new Uri("/getcountrydata/" + country_name + "/" + arms[0].Name + "/" + arms[1].Name + "/" + arms[2].Name + "/" + arms[3].Name, UriKind.Relative);
var webClient = new WebClient();
webClient.OpenReadCompleted += openReadCompleted;
webClient.OpenReadAsync(serviceUri);
}
Global.asax中路由如下:
routes.MapRoute(
"getcountrydata",
"getcountrydata/{country}/{indicator1}/{indicator2}/{indicator3}/{indicator4}",
new { controller = "Home", action = "getcountrydata" }
);
的getcountrydata方法如下:
public JsonResult getcountrydata(string country, string indicator1, string indicator2, string indicator3, string indicator4)
{
LegoData legoData = captainClimateRepostory.GetLegoData(country, indicator1, indicator2, indicator3, indicator4);
DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(LegoData));
MemoryStream ms = new MemoryStream();
ser.WriteObject(ms, legoData);
return Json(ms.ToArray(), JsonRequestBehavior.AllowGet);
}
你知道你的托管服务提供商使用的是什么版本的IIS吗?你应该能够在firebug响应头文件中看到它。 – russau 2012-03-14 04:56:15
他们正在使用Microsoft-IIS/7.5 – 2012-03-14 05:05:28
使用Firefox上的REST客户端来测试你的服务,一旦你得到它的工作,你可以尝试修复这段代码! – 2012-03-14 06:44:37