ASPNET MVC: я получаю сообщение об ошибке "Представление X или его мастер не найдены или отсутствует обработчик представления..." в методе, возвращающем JSON ContentResult
У меня есть метод, который возвращает JSON ContentResult. Я призываю из файла JavaScript, как это:
$scope.GetUserRoles = function () {
$http({
method: "GET",
url: Current.VirtualUrl + "Store/Counting/GetUserRoles"
}).then(function mySucces(response) {
if (response.data.Status == 1) {
$scope.UserRoles = response.data.Data;
$scope.GetCountingList(0, false, "CountingId", "DESC");
}
else {
console.log(response);
$scope.ShowMessage(msgWarning, msgDataFromServerFail + response.data.Data);
}
}, function myError(response) {
});
}
При вызове здесь метод GetUserRoles не срабатывает и Response.Data получает эту ошибку:
<link href="/MySite/Assets/css/pages/error.css" rel="stylesheet" />
<div class="page-500-full-page">
<div class="row">
<div class="col-md-12 page-500">
<div class=" number">
500
</div>
<div>
<h3>Oops! Something went wrong.</h3>
<p>
The view 'GetUserRoles' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Areas/iStore/Views/Counting/GetUserRoles.aspx
~/Areas/iStore/Views/Counting/GetUserRoles.ascx
~/Areas/iStore/Views/Shared/GetUserRoles.aspx
~/Areas/iStore/Views/Shared/GetUserRoles.ascx
~/Views/Counting/GetUserRoles.aspx
~/Views/Counting/GetUserRoles.ascx
~/Views/Shared/GetUserRoles.aspx
~/Views/Shared/GetUserRoles.ascx
~/Areas/iStore/Views/Counting/GetUserRoles.cshtml
~/Areas/iStore/Views/Counting/GetUserRoles.vbhtml
~/Areas/iStore/Views/Shared/GetUserRoles.cshtml
~/Areas/iStore/Views/Shared/GetUserRoles.vbhtml
~/Views/Counting/GetUserRoles.cshtml
~/Views/Counting/GetUserRoles.vbhtml
~/Views/Shared/GetUserRoles.cshtml
~/Views/Shared/GetUserRoles.vbhtml </p>
</div>
</div>
</div>
</div>
Любая помощь будет высоко ценится.
Заранее спасибо.
2 ответа
Решение
Я нашел проблему. Базовый класс контроллера переопределяет метод OnActionExecuting. И если условие не может прийти сюда.
Спасибо за все ваши советы.
Попробуйте заменить:
url: Current.VirtualUrl + "Store/Counting/GetUserRoles"
с этим:
url:"/Store/Counting/GetUserRoles"
или убедитесь, что у вас есть:
url:"/ControllerName/MethodName"
в URL