0
我有兩個項目Asp.net Core
和Asp.net Mvc
。 我魔杖與angualrjs發送數據從Asp.net核心到Asp.net Mvc與angualrjs
發送從第一個項目(Asp.net Core
)到第二個項目(Asp.net Mvc
)數據,當我運行兩個項目,我的問題是,當我想從Asp.net Core
發佈模型ActionResult
在Asp.net Mvc
,這ActionResult
沒有價值。
Angularjs在第一個項目(Asp.net Core
):
$rootScope.PrintCArd2 = function() {
$scope.TblFishCar = {};
$scope.TblFishCar.IdFish = $rootScope.TblFishCarIdFish;
$http.post("http://localhost:61779/Report/GetFishReport", $scope.TblFishCar).then(function (result) {
alert("Ok2");
},
function (e) {
alert("warning"+e);
});
};
的ActionResult在第二projcet(Asp.net Mvc
):
public class ReportController : Controller
{
[System.Web.Http.HttpPost]
public ActionResult GetFishReport([FromBody]TblFishCar model)
{
//do something
return PartialView("_ShowReport");
}
}
angularjs呼籲公衆ActionResult GetFishReport([FromBody]TblFishCar model)
但模式並不具有價值。
TblFishCar:
public partial class TblFishCar
{
public Guid IdFish { get; set; }
public int ShFish { get; set; }
public string DateFish { get; set; }
}
我怎樣才能解決這個問題?
你能告訴你的'TblFishCar model'類?此外,請參閱此答案 - https://stackoverflow.com/questions/30957248/how-to-send-post-in-angularjs-with-multiple-params/30957308#30957308 – Sajal
是編輯我的帖子 –
更改'Guid'爲模型類中的'string'並從method參數中移除'[FromBody]'。稍後可以在方法體中將字符串強制轉換爲GUID(如果需要的話!)。 – Sajal