C# 从字符串强制转换为HttpError或从HttpResponseMessage获取HttpError,是否可能?

C# 从字符串强制转换为HttpError或从HttpResponseMessage获取HttpError,是否可能?,c#,asp.net,.net,http,http-error,C#,Asp.net,.net,Http,Http Error,是否可以从字符串强制转换为HttpError对象 HttpResponseMessage response= _controller.AddFeedback(Guid.NewGuid(),feedbackSessionDto); // Assert string message = response.Content.ReadAsStringAsync().Result; 消息为,看起来像这样“{\”消息\“:\”更新\“}”时出错 我想要httpErr

是否可以从字符串强制转换为HttpError对象

HttpResponseMessage response= 
 _controller.AddFeedback(Guid.NewGuid(),feedbackSessionDto);
            // Assert
       string message = response.Content.ReadAsStringAsync().Result;
消息为,看起来像这样“{\”消息\“:\”更新\“}”时出错


我想要httpError

你说的“httpError”是什么意思?我想要消息将作为system.Web.Http中的httpError类,我只能获取消息,因此它将只是字符串“Error while update\”,为什么不解析JSON呢?(我认为HttpError的存在是为了方便ASP.NET用户提供错误信息-我不认为它映射到HTTP本身的任何特定内容,因此从客户端的角度来看,我会感到惊讶。)我假设您包含的反斜杠实际上不在字符串中,您之所以显示它们,是因为调试器显示了它们……您所说的“httpError”是什么意思?我希望消息将作为system.Web.Http中的httpError类,我只能获取消息,因此它将只是字符串“Error while update\”,为什么不解析JSON呢?(我认为HttpError的存在是为了方便ASP.NET用户提供错误信息-我不认为它映射到HTTP本身的任何特定内容,因此从客户端的角度来看,我会感到惊讶。)我假设您包含的反斜杠实际上不在字符串中,您之所以显示它们,是因为调试器显示了它们。。。