Zidane Zidane - 1 year ago 80
ASP.NET (C#) Question

Break point not being hit on controller but data from controller is returned

I am using knockout java-script and I have an api call to a controller , this same controller has a number of methods that all work fine
however when I place a break point on one particular method it is never hits that break point . This is quite mind boggling because when I place a break point in my java-script I can see that there is data coming back from that particular method in the controller . Does anyone have any idea what might be causing this ?

this is my knockout

function FetchDeviceRows(dtvm, item) {
$.when(getSecureData("/api/DeviceHierarchy?parentCostCentreId=" + item.assetInstanceId() + "&noChildren=" + item.noChildren() + "&orgLevel=" + item.orgLevel()))
.done(function (rows) {
InsertActualDeviceRows(dtvm, item, rows);

this is my DeviceHierachy Controller method which is being accesed by my knockout . The break point here is not hit but when I put a break point on
.done(function (rows) in my knockout it shows that it has returned data

public IEnumerable<DeviceHierarchyRow> Get(int parentAssetInstanceId, int noChildren, int orgLevel)
var hierarchies = _deviceHierarchyRepository.GetDevices(parentAssetInstanceId, noChildren);
return hierarchies.ToList().Select(h => new DeviceHierarchyRow(orgLevel + 1, 0, 0, "", "", h.noChildren, _pageSize, false));

Answer Source

Your Query string is invaild.
Since you have not set a default value for the parameter parentAssetInstanceId on your web api, which means it is a default parameter and since you are passing parentCostCentreId the api cannot find a value for parentAssetInstanceId and returns a 500 internal server error, you should see this in your js console. Unless you have another get method that then takes in parentCostCentreId in which case your break point is in the wrong place.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download