The view 'Index' or its master was not found.

后端 未结 17 2224
逝去的感伤
逝去的感伤 2020-12-15 14:42
The view \'Index\' or its master was not found. The following locations were searched:
~/Views/ControllerName/Index.aspx
~/Views/ControllerName/Index.ascx
~/Views/Sh         


        
17条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-15 15:25

    If You can get this error even with all the correct MapRoutes in your area registration and all other basic configurations are fine.

    This is the situation:

    I have used below mentioned code from Jquery file to post back data and then load a view from controller action method.

    $.post("/Customers/ReturnRetailOnlySales", {petKey: '<%: Model.PetKey %>'}); 
    

    Above jQuery code I didn't mentioned success callback function. What was happened there is after finishing a post back scenario on action method, without routing to my expected view it came back to Jquery side and gave view not found error as above.

    Then I gave a solution like below and its working without any problem.

     $.post("/Customers/ReturnRetailOnlySales", {petKey: '<%: Model.PetKey %>'},
          function (data) {
     var url = Sys.Url.route('PetDetail', { action: "ReturnRetailOnlySalesItems", controller: "Customers",petKey: '<%: Model.PetKey %>'});
     window.location = url;});   
    

    Note: I sent my request inside the success callback function to my expected views action method.Then view engine found a relevant area's view file and load correctly.

提交回复
热议问题