Search code examples
javascriptasp.net-mvcactionresultfilecontentresult

ASPNET MVC: I get "The view X or its master was not found or no view engine..." Error on Method that return JSON ContentResult


I have a method that return json ContentResult. I call on from JavaScript file like this:

 $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) {
        });
    }

When calling here GetUserRoles method doesn't fire and Response.Data get this error:

<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 &#39;GetUserRoles&#39; 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>

Any help will be much appreciated.

Thanks in advance.


Solution

  • I found the problem. Base controller class override OnActionExecuting method. And an if condition prevent coming here.

    Thanks for your all advices.