I am trying to get FileInfo result from a controller but it returns always 500 . Files exists and no error found. All middleware's and controller works fine but I don't know why i get however 500 status code. what i Have tried is given below.
1.
public ActionResult GetFileinfo(string filePath) {
FileInfo fileInfo = new FileInfo("C:\\Mw_Prog\\Ema.txt") ;
if(fileInfo.Exists)
return Ok(fileInfo) ;
else
return StatusCode(404,"NOT FOUND");
}
public FileInfo GetFileinfo(string filePath) {
FileInfo fileInfo = new FileInfo("C:\\Mw_Prog\\Ema.txt") ;
if(fileInfo.Exists)
return fileInfo ;
else
return null;
}
After I Checked some backgroung functionality and found Exception in RecourseInvoker.cs class.
System.Text.Json.JsonException: "A possible object cycle was detected. This can either be due to a cycle or if the object depth is larger than the maximum allowed depth of 32. Consider using ReferenceHandler.Preserve on JsonSerializerOptions to support cycles. Path: $.Directory.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Root.Name."
Anyone Know what that means ?
Did you try sending Ok() alone? Perhaps the response body (sending FileInfo) is larger than the configured limit
PD: Not reputation for adding a comment instead of answer