내가 ajax 함수를 가지고 있고 SomeAction
작업 에서 예외가 발생했다고 가정 해 보겠습니다 .
function CallAjaxFunction() {
$.ajax({
url: '/Home/SomeAction',
success: function (response) {
//do something
},
error: function (response) {
//redirect to Developer Exception Page to show detailed error
}
});
}
를 사용하여 오류 페이지로 리디렉션 할 수 있다는 것을 알고 window.location = "/Home/Error";
있지만 더 자세한 정보를 표시하기 위해 브라우저를 개발자 예외 페이지로 리디렉션하려면 어떻게해야합니까?
나는 여기서 근본적인 것을 오해하고 있을지도 모른다 (이 질문을하는 큰 이유이다). 그래서 개념에 대한 설명을 주시면 감사하겠습니다.
더 자세한 정보를 표시하기 위해 브라우저를 개발자 예외 페이지로 리디렉션하려면 어떻게해야합니까?
에서 "ASP.NET 코어의 핸들 오류"에 대한이 doc , 당신은 찾아 낼 것입니다 :
Enable the Developer Exception Page only when the app is running in the Development environment. You don't want to share detailed exception information publicly when the app runs in production.
일반적으로 더 나은 사용자 경험을 위해 클라이언트 사용자에게 직접 오류 페이지를 표시하지 않습니다.
일부 오류로 인해 ajax 요청이 실패하는 동안 브라우저 사용자에게 Developer Exception Page를 표시하려면 다음 샘플을 참조하십시오.
$.ajax({
url: '/Home/MyTestAction',
dataType: "html",
success: function (response) {
//do something
},
error: function (response) {
//console.log(response);
document.write(response.responseText);
}
});
MyTestAction의 코드
public IActionResult MyTestAction()
{
Convert.ToDateTime("hello");
return Ok("success");
}
검사 결과
위의 오류 콜백 기능이 실행되면 아래와 같은 자세한 오류 메시지가 페이지에 표시됩니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다