我有一個網頁,使AJAX請求更新頁面上的小定價部分。它在我的本地機器上運行時正常工作,但是當發佈到我們的開發服務器時,AJAX調用收到內部服務器錯誤500響應。我迷失的部分是當我附加調試器並逐步執行代碼時,動作似乎成功完成,所以看起來好像發生了一些事情動作方法運行導致500但我不知道任何代碼在操作方法之後運行。Asp.NET操作方法成功,但瀏覽器接收500與jQuery.ajax
這裏是的.js AJAX,動作方法,其響應:
_paymentPlanXhr = $.ajax({
type: "POST",
url: $("#_Booking_UpdatePaymentUrl").val(),
data: "purchaseMem="+ purchaseMem +"&sid=" + selectedStudentID,
cache: false,
dataType: "json",
timeout: 120000,
success: function (response) {
...
},
error: function (jqXHR, textStatus, errorThrow) {
_paymentPlanXhr = null;
$loadingDiv.hide();
_pendingPaymentPlanUpdate = false;
//If this was really an error, not the result of our code cancelling the request
if (textStatus != "abort")
$("#divPaymentLoadError").show();
}
});
處理法:
[HttpPost]
public ContentResult Booking_UpdatePayment(PsnBookingPage currentPage, bool purchaseMem, Guid sid)
{
AjaxResponse result = new AjaxResponse();
BookingViewModel bookingVM = new BookingViewModel();
try
{
//Code for building the vm omitted for brevity since it succeeds.
result.Content = this.RenderPartialView(_paymentViewUrl, viewModel, true);
}
catch (Exception ex)
{
viewModel.AbortView = true;
viewModel.AbortMessage = "We're sorry! Something went wrong and we were unable to load the view.";
}
return result.ToContentResult();
}
result.ToContentResult:
{"HasError":false,"ErrorMessage":null,"Content":" <div id=\"divSelectDate\"><div class=\"data-price\">Due Today: $20.00</div><div class=\"data-price\">Due on Event Date: $0.00</div></div>","Data":null}
我不不知道這是否是一個因素,但這是一個基於EPiServer的網站。我怎樣才能找到500的來源?
編輯:
也許是因爲即使我已經自定義錯誤關閉時,我的反應與500弄,這是關係到EPiServer具有以下代替黃色asp.net錯誤畫面:
<html>
<head>
<meta name="robots" content="noindex,nofollow"><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>
Page could not be loaded
</title>
<style type="text/css">
body{font-size:65%;color:black;background-color:White;}
form{font-size:1.2em;}
body,table{font-family:Verdana;font-weight:normal;}
h1{color: gray;font-size: 1.4em;font-family:Verdana;margin:0.5em 0 0 0;}
h2{font-size:1.2em;font-weight:bold;}
h3{display: inline;font-weight:bold;font-size: 1.0em;}
.ExceptionInfo{margin:0.6em 0 0.6em 0.2em;}
.StackTrace{font-family:"Lucida Console";}
th{font-size: 0.8em;text-align:left;white-space: nowrap;}
td{font-size: 0.7em;}
.DetailedHeader{font-weight:bold;border: 1px solid black;padding:4px;text-align:center;}
.ReportForm{font-family:Verdana;font-weight:normal;font-size: 1.0em;color:black;}
.SubmitButton{font-family:Verdana;font-weight:normal;font-size: 1.0em;color:black;}
</style>
<script type="text/javascript">
<!--
function onNavigate(newPageLink)
{
return -1;
}
function onCommand(newCommand)
{
return -1;
}
// -->
</script>
</head><body>
<h1 class="Title">
Page could not be loaded
</h1><p style="width:40em;">The link you specified does not work. This may either be the result of temporary maintenance or an incorrect link.
</p></body></html>
我認爲這是一個鉻頁面,但另一個線程建議它是一個EPiServer生成的頁面。
據我瞭解,您不能更改服務器上應用程序的自定義錯誤屬性? – c0demaster
我可以在服務器上更改我們想要的任何內容,因爲它只是一個開發服務器。自定義錯誤目前關閉。 – xr280xr
好了,關閉remoteonly和customerrors屬性並給我們提供錯誤。 – c0demaster