简体   繁体   中英

Server throws an exception only when debugging

I have an api call to search an object from my data base with 3 fields. (string, datetimestart, datetimeend). When I execute this it works perfectly:

entryAPI.entriesSearch = function (item) {
    return $http.post("./api/search/", { Matter: item.Matter, StartDate: item.StartDate, EndDate: item.EndDate});
};

The problem is that when I attach debugger and put a breakpoint in the call, the item receiving seems to be null and obviously it throws an exception.

public HttpResponseMessage Post(Entities.TimeSheet.SearchFields item)
{
    try
    {
        // do some stuff (that is correctly done when not debugging
        // item value is null when debugging
    }

This is my SearchFields item:

public class SearchFields
{
    public string Matter { get; set; }
    public DateTime StartDate { get; set; }
    public DateTime EndDate { get; set; }
}

The search works perfectly fine but I want to track some values now and I am not able to do so, I have no idea how to solve/search how to solve something like this.

Thanks in advance.

I think [FromBody] is missing.

Like:

public HttpResponseMessage Post([FromBody] Entities.TimeSheet.SearchFields item)
{
    try
    {
        // do some stuff (that is correctly done when not debugging
        // item value is null when debugging
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM