[英]ASPNET MVC: I get “The view X or its master was not found or no view engine…” Error on Method that return 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>
任何幫助都感激不盡。
提前致謝。
嘗試更換:
url: Current.VirtualUrl + "Store/Counting/GetUserRoles"
有了這個:
url:"/Store/Counting/GetUserRoles"
或確保您具有:
url:"/ControllerName/MethodName"
在網址中
我發現了問題。 基本控制器類重寫OnActionExecuting方法。 並且如果情況阻止來到這里。
感謝您的所有建議。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.