private Dictionary <string, object> GetDebugLogs(VueForm form) { if (form.Debug?.Value == true) { var debugDictionary = HttpContext.Items .Where(x => (x.Key as string)?.StartsWith(Constants.VueFormDebugLog) == true) .ToDictionary(kvp => ((string)kvp.Key).Replace(Constants.VueFormDebugLog, ""), kvp => kvp.Value); var files = Request.Form.Files.Select(f => new { f.FileName, f.Name, f.ContentType, f.Length }); debugDictionary.Add("Request.Files", files); return(debugDictionary); } return(null); }
private object EvaluateScript(string script, VueFormMethodsProvider scriptingProvider, VueForm form, string scriptName) { object result = null; if (!string.IsNullOrWhiteSpace(script)) { try { result = _scriptingManager.EvaluateJs(script, scriptingProvider); } catch (Exception ex) { _logger.LogError(ex, $"An error occurred evaluating the {scriptName} script"); if (form.Debug?.Value == true) { HttpContext.Items.TryAdd($"{Constants.VueFormDebugLog}Script_{scriptName}", ex.ToString()); } ModelState.AddModelError("serverErrorMessage", S["A unhandled error occured while executing your request."].ToString()); } } return(result); }