如何解决asp.net mvc中的路径问题

时间:2017-08-30 13:28:40

标签: asp.net-mvc

在视图中,我从控制器获取JSON数据。 Path在我的本地工作但不在其他服务器中工作。

$。get('../ TestController / GetTestResultById?Id ='+ s.GetValue(),function(data){        一些数据 }

这是我在本地获取数据的格式,但在不同的服务器中,路径应该是appname / controllername / ....但是获取为controllername / .... 如何解决这个问题。

1 个答案:

答案 0 :(得分:-1)

var myUrl = '@Url.Action("GetTestResultById","Test")';
//It will create your url where you want to call ajax.


//then append Id with url and your value.
$.get(myUrl + "?Id=" + s.GetValue(), function (data) { 
    // Use `data` here
});
相关问题