locked
Partial Views not found. RRS feed

  • Question

  • User1421620300 posted

    Is their a possible explanation or a quick for to the following error. Application is clean on compile time. SPA application with CRUD partial views using .cshtml. Index view works all other crud views do not! Please help. Markus

    Here is the Link to the project if anyone wants to take a look at it! https://github.com/Andrew112/MVC_Using_Angular

    Server Error in '/' Application.


    The partial view 'ShowEmployees' was not found or no view engine supports the searched locations. The following locations were searched:
    ~/Views/EmployeeInfo/ShowEmployees.aspx
    ~/Views/EmployeeInfo/ShowEmployees.ascx
    ~/Views/Shared/ShowEmployees.aspx
    ~/Views/Shared/ShowEmployees.ascx
    ~/Views/EmployeeInfo/ShowEmployees.cshtml
    ~/Views/EmployeeInfo/ShowEmployees.vbhtml
    ~/Views/Shared/ShowEmployees.cshtml
    ~/Views/Shared/ShowEmployees.vbhtml

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.InvalidOperationException: The partial view 'ShowEmployees' was not found or no view engine supports the searched locations. The following locations were searched:
    ~/Views/EmployeeInfo/ShowEmployees.aspx
    ~/Views/EmployeeInfo/ShowEmployees.ascx
    ~/Views/Shared/ShowEmployees.aspx
    ~/Views/Shared/ShowEmployees.ascx
    ~/Views/EmployeeInfo/ShowEmployees.cshtml
    ~/Views/EmployeeInfo/ShowEmployees.vbhtml
    ~/Views/Shared/ShowEmployees.cshtml
    ~/Views/Shared/ShowEmployees.vbhtml

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace:

    [InvalidOperationException: The partial view 'ShowEmployees' was not found or no view engine supports the searched locations. The following locations were searched:
    ~/Views/EmployeeInfo/ShowEmployees.aspx
    ~/Views/EmployeeInfo/ShowEmployees.ascx
    ~/Views/Shared/ShowEmployees.aspx
    ~/Views/Shared/ShowEmployees.ascx
    ~/Views/EmployeeInfo/ShowEmployees.cshtml
    ~/Views/EmployeeInfo/ShowEmployees.vbhtml
    ~/Views/Shared/ShowEmployees.cshtml
    ~/Views/Shared/ShowEmployees.vbhtml]
       System.Web.Mvc.PartialViewResult.FindView(ControllerContext context) +369
       System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +116
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
       System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
       System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +198
       System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +100
       System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
       System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45
       System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
       System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
       System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28
       System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
       System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
       System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9847493
       System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +50
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163
    

     


    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4110.0

    Monday, May 4, 2020 2:52 PM

Answers

  • User1535942433 posted

    Hi Markus33,

    Accroding to your description and code,I create a test of your code in github.When I click the <a href> of showemployees,it will show the error of 'The partial view 'ShowEmployees' was not found or no view engine supports the searched locations.'

    From your codes of view and controller,you lost the view's name of 'ShowEmployees'.So it will have this error.I suggest you could create a view which name is ShowEmployees in your curent filefolder.

    Just do this:

    Result:

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 14, 2020 8:13 AM

All replies

  • User1535942433 posted

    Hi Markus33,

    Accroding to your description , as far as I think, you could check if it is a typo  or the file is not in one of the searched folder.I suggest you could ensure that you provide the full path to the partial with the extension.

    More details,you could refer to below article:

    https://forums.asp.net/t/2137905.aspx?Partial+view+is+not+found

    Best regards,

    Yijing Sun

    Tuesday, May 5, 2020 6:40 AM
  • User1421620300 posted

    Yij, you can view the project on GitHub here is the link, Thanks Markus

    https://github.com/Andrew112/MVC_Using_Angular

    Friday, May 8, 2020 12:14 AM
  • User1535942433 posted

    Hi Markus33,

    Accroding to your description and coded,I suggest you could create a view named ShowEmployees.In your view,I cann't find the ShowEmployees view.However,in your controller,you have returned the partial view of ShowEmployees .The action of  return PartialView("ShowEmployees") means the action will return ShowEmployees View.

    If you want to load PartialView,there are two methods:

    Method 1:

    First you need to make an action to the controller like this in your view

    @{Html.RenderAction("youractionname", "controllername");}

    and then on controller you need to return partial view like this

    public ActionResult youractionname()
            {
                return PartialView("~/Areas/Admin/Views/Shared/_AddUser.cshtml");
            } 

    Method 2:

    You can use ajax to load the partialview without refreshing the browser.

    First you need to add a div with some id where you need to load the partial view.

    <div id="PartialId"></div>

    then you need to add the action link (on click of the link partial view will be loaded)

    <a href="javascript:Details()">Select</a>

    Your ajax method looks like below

    <script>
        function Details() {
            jQuery.ajax({
                url: '@Url.Action("index", "Home")', // your action method
                method: "POST", // your method
                cache: false,
                data: { }
            }).done(function (result) {
                $('#PartialId').html(result);
            });
        }
    </script>

    Best regards,

    Yijing Sun

    Tuesday, May 12, 2020 9:30 AM
  • User1421620300 posted

    Yij, if you clone the project from the Github repo. You can recreate the error for me! And then tell me what is broken within application? All of the suggestions do not meet the need of fixing current code or making current code use-able. Markus

    Tuesday, May 12, 2020 3:01 PM
  • User1535942433 posted

    Hi Markus33,

    Accroding to your description and code,I create a test of your code in github.When I click the <a href> of showemployees,it will show the error of 'The partial view 'ShowEmployees' was not found or no view engine supports the searched locations.'

    From your codes of view and controller,you lost the view's name of 'ShowEmployees'.So it will have this error.I suggest you could create a view which name is ShowEmployees in your curent filefolder.

    Just do this:

    Result:

    Best regards,

    Yijing Sun

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 14, 2020 8:13 AM
  • User1421620300 posted

    Thanks YijSun, i am glad that you were able to help me. It seems as if i would have had to put this project on the back-burner if not for your help." Thanks again. Markus

    Thursday, May 14, 2020 1:23 PM