How to return DataTable from .NET Web Service?

I was able to return the HashTable from the web service that I installed for .NET 2.0, but the service was unable to reconfigure the DataTable to JSON. I keep getting the following error: "The circular link was detected while serializing the object." Any tips?

 [WebMethod(EnableSession = true) ]
public DataTable getSavedAddresses()
{
    DataTable dt = new DataTable();
    if (Session["ClientID"] != null)
    {
        int clientId = Convert.ToInt32(Session["ClientID"]);
        dt = Address.GetClientShippingAddresses(clientId);
    }
    return dt;

}

+3
source share
1 answer

A circular reference is probably associated with DataTablehaving a property Columns, and each object DataColumnhas a property Table.

The information in this Rick Thrall blog post may help you, perhaps.

+1
source

Source: https://habr.com/ru/post/1708904/


All Articles