Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8275103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T07:57:46+00:00 2026-06-08T07:57:46+00:00

If I have a Customer class that just has simple properties (e.g. Name ,

  • 0

If I have a Customer class that just has simple properties (e.g. Name, etc.) then I can create a CustomersController that derives from ApiController, and query my Customer objects using the URL /api/customers.

Similarly, if I have an Order class with simple properties (Description, Amount) then I can create an OrdersController and access it in the same way.

However, if I then add a property to my Customer class that lists the Orders associated with that Customer:

public class Customer
{
    public int Id { get; set; }
    public string Name { get; set; }
    // ...
    public virtual ICollection<Order> Orders { get; set; }
}

…then when I try to query using /api/customers I get a 500 Server Error. I can put a breakpoint within the CustomersController and can see that it does call the correct method, and attempts to return a value. However, somewhere in the guts of the framework it fails to turn that into an HTTP response.

It looks like it cannot serialize the Orders information and/or package it up for the HTTP response, but I’m not sure what I need to do to make this happen. Or is it simply the case that the WebApi stuff is not designed to return complex objects?


Update: my code is here: https://gist.github.com/43ed2f29f8adfb44cef6


Update 2: more information on the error I get:

Server error
The website encountered an error while retrieving http://localhost:1031/api/customers/6.

It may be down for maintenance
or configured incorrectly.
Here are some suggestions:
Reload this webpage later.
HTTP Error 500 (Internal Server Error): An unexpected condition was encountered while the server was attempting to fulfill the
request.

The Intellitrace log shows the following: https://i.stack.imgur.com/8R1XL.png

[I can hardly believe that the Intellitrace window does not allow me to copy the text, so that I had to actually print-screen and upload an image. What year is this?]


Related: ASP.Net Web API showing correctly in VS but giving HTTP500

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T07:57:49+00:00Added an answer on June 8, 2026 at 7:57 am

    You are passing an Entity Framework entity which will cause problems. You need Data Transfer Objects to pass and receive your data. Because you bind entities together, it won’t allow you to serialize the data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently i have a customer class that the user can partially create, and finish
Say I have a class Customer which has a property FirstName . Then I
Say we have a class of Customer and that has a child object of
I have a Customer class that contains a property, MyProperty, which is of a
Suppose I have a class Customer that is mapped to the database and everything
what i mean by that is: i have a class called Customer: public class
I have a Customer class which has a representative field....this field is initially blank
I have these 3 models in models.py class Customer(models.Model): name = models.CharField(max_length=50) .... class
Let's say I have a class Customer, which has a property customerType. I have
I have a domain model that includes something like this: public class Customer :

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.