I am creating a asp.net Web API service end point which return a bulk data from the oracle database. I am converting the returned data in the JSON format. It was working fine, but suddenly I am getting an error saying Out of Memory exception in the string result.
public HttpResponseMessage Getdetails([FromUri] string[] id)
{
using (OracleConnection dbconn = new OracleConnection("DATA SOURCE=J;PASSWORD=C;PERSIST SECURITY INFO=True;USER ID=T"))
{
var inconditions = id.Distinct().ToArray();
var srtcon = string.Join(",", inconditions);
DataSet userDataset = new DataSet();
var strQuery = @"SELECT * from STCD_PRIO_CATEGORY where STPR_STUDY.STD_REF IN(" + srtcon + ")";
OracleCommand selectCommand = new OracleCommand(strQuery, dbconn);
OracleDataAdapter adapter = new OracleDataAdapter(selectCommand);
DataTable selectResults = new DataTable();
adapter.Fill(selectResults);
string result = JsonConvert.SerializeObject(selectResults);
string contentDisposition = "inline; filename=ProvantisStudyData.json";
//byte[] byteInfo = Encoding.ASCII.GetBytes(result);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, result, MediaTypeHeaderValue.Parse("application/json"));
response.Content.Headers.ContentDisposition = ContentDispositionHeaderValue.Parse(contentDisposition);
//response.Content.Headers.ContentLength = byteInfo.Length;
return response;
}
}
Above the code I am using. I am not sure why I am geting the exeception suddelny and why sometimes it is working. Any help is greatly appreciated.