【发布时间】:2018-06-06 12:46:33
【问题描述】:
我尝试使用自定义 StatusDescription 将消息与我的内容一起发送给客户端。在我的本地机器上它可以工作,但在 Azure 上却不行。有人知道为什么吗?
问候,亚历克斯
更新:
[HttpPost]
[ValidateAntiForgeryToken(Order = 1)]
public ActionResult SaveCustomer(KundenViewModel viewModel)
{
/*
* Do some additional stuff here
*/
try
{
// Save the customer in database
SaveCustomerToDatabase(viewModel);
Response.StatusCode = (int)HttpStatusCode.OK;
Response.StatusDescription = Global.SaveCustomerSuccess; // <--- Try to response a message
return PartialView("_CustomerTable", GetCustomerViewModel();
}
catch (Exception e)
{
Logger.LogException(e, HttpContext);
Response.StatusCode = (int)HttpStatusCode.InternalServerError;
Response.StatusDescription = Global.GeneralErrorInternal; // <--- Try to response a message
return null;
}
}
在客户端我尝试显示消息:
MyNamespace.customerSaveSuccess = function (data, textStatus, jqXHR) {
MyNamespace.Notification.Success(jqXHR.statusText);
_ToggleTabs(false);
};
如果我在本地尝试它会完美运行,但一旦我将它发布到 Azure,我只会收到默认状态代码消息“OK”而不是我的自定义文本
【问题讨论】:
-
如果没有看到您的任何自定义代码,我们怎么可能知道?
-
简而言之:不。再长一点:请确保我们可以检查您遇到的情况,例如通过添加(相关)代码。更多信息请参考这篇文章:minimal reproducible example
-
@rickvdbosch OP 提供了一些代码。
标签: c# asp.net-mvc azure