I've a model class like this:-
public class InternShip
{
[Key]
public int ID { get; set; }
public string Name { get; set; }
public string Descr { get; set; }
public int Amount { get; set; }
public int Duration { get; set; }
public DateTime CreatedDate { get; set; }
public DateTime ExpiryDate { get; set; }
}
Now I've a view in which I've created ng-click event:-
<a ng-click="IntrnDetail(r.ID)" style="cursor:pointer"><h5>{{r.Name}}</h5></a>
On Click my value passes to my angular file InternShip.js where it is handeled by function:-
$scope.IntrnDetail = function (InternID) {
window.location.href = '/Home/InternDetail/' + InternID;
}
Now My Controller (HomeController) has ActionResult(InternDetail) as:-
[HttpGet]
public JsonResult InternDetail(string InterID)
{
List<InternShip> Intern = new List<InternShip>();
int IntID = Convert.ToInt32(InterID);
using (EBContext db = new EBContext())
{
Intern = db.Interns.Where(x => x.ID == IntID).ToList();
}
return new JsonResult{ Data= Intern, JsonRequestBehavior=JsonRequestBehavior.AllowGet};
}
But the problem is although value is coming inside InternID of InternShip.js but in JsonResult (InternDetail) InterID is getting null. I don't know why is that happening.
Please HELP!!