ok

alphons <alphons@heijden.com> 11 Dec 2024, 16:58
d8bd98adef704f2f1cb818019cece328f9d52c90
1 files changed
  • WebFormBuilder/Controllers/FormConfigController.cs
diff --git a/WebFormBuilder/Controllers/FormConfigController.cs b/WebFormBuilder/Controllers/FormConfigController.cs
index 98d2064..7452345 100644
--- a/WebFormBuilder/Controllers/FormConfigController.cs
+++ b/WebFormBuilder/Controllers/FormConfigController.cs
@@ -15,14 +15,21 @@ public class FormConfigController : ControllerBase
var jsonFilePath = Path.Combine(AppContext.BaseDirectory, "formConfigData.json");
- if (System.IO.File.Exists(jsonFilePath))
- {
- var jsonData = await System.IO.File.ReadAllTextAsync(jsonFilePath);
- list = JsonSerializer.Deserialize<List<FormField>>(jsonData);
- }
+ if (!System.IO.File.Exists(jsonFilePath))
+ return NotFound();
- list ??= FormConfigData.FormFields;
+ var stream = new FileStream(jsonFilePath, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize: 4096, useAsync: true);
- return Ok(list);
+ return File(stream, "application/json");
+
+ //var jsonData = await System.IO.File.ReadAllTextAsync(jsonFilePath);
+
+ //return Content(jsonData, "application/json");
+
+ //list = JsonSerializer.Deserialize<List<FormField>>(jsonData);
+
+ // list ??= FormConfigData.FormFields;
+
+ //return Ok(list);
}
}