0

When request by client app, Timeout occurs. I set breakpoints to check if the parameters were entered well in the controller method, and it looks fine.

Even after a while, an System.AccessViolationException occurs and my app crashes.

My Controller Code is here.

namespace REST_API_EX.Controllers 
{
    public class DeliveriesController : ApiController
    {
        private DatabaseContext db = new DatabaseContext();

        [ResponseType(typeof(Delivery))]
        public async Task<IHttpActionResult> GetDeliveryByOrder_No(string Order_No)
        {
            Delivery delivery = await db.Deliveries
                .Where(d => d.Order_No == Order_No)
                .FirstAsync();
            if (delivery == null)
            {
                return NotFound();
            }
            return Ok(delivery);
        }
    }
}
2
  • What does the Delivery class look like? Commented Jun 2, 2017 at 16:22
  • Those kind of issues are often related to complex objects structures (with loop references or many nested navigation properties) that will cause big troubles when serialized in json. To exclude those kind of issues I strongly suggest you to map your return types into simpler objects with only the properties needed client-side. Commented Jun 4, 2017 at 20:13

1 Answer 1

1

since you're using EF6. try

public class DeliveriesController : ApiController{
db.Configuration.LazyLoadingEnabled = false

// Your Code

}

because EF tries to load the reference but end up looping in that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.