我有这样的代码:
public void Put(int id, DistributionRuleModelListItem model)
{
CommonResultModel pre = new BLL.DistributionRules().Save(id, model, true);
if(!pre.success){
DAL.DBManager.DestroyContext();
var resp = new HttpResponseMessage(HttpStatusCode.InternalServerError)
{
Content = new StringContent(string.Format("Internal server error for distruleId: {0}", id)),
ReasonPhrase = pre.message.Replace(Environment.NewLine, " ")//.Substring(0,400)
};
throw new HttpResponseException(resp);
}
}有一种逻辑可以将pre.message的值设置为exception.ToString(),如果太长,我将收到以下应用程序异常:
指定的参数超出了有效值范围。参数名称:值
但是,如果我取消注释.Substring(0,400),一切都可以正常工作,并且在客户端,我收到正确的响应,并且可以向用户显示它。
ReasonPhrase的最大长度是多少?我找不到任何指定此值的文档。
发布于 2015-06-08 17:18:06
我在任何地方都找不到最大值,但是经过反复试验,我发现它的最大长度为512字节。
https://stackoverflow.com/questions/25890396
复制相似问题