The view or its master was not found or no view engine supports the searched locations

前端 未结 14 2150
挽巷
挽巷 2020-12-02 15:05

Error like:The view \'LoginRegister\' or its master was not found or no view engine supports the searched locations. The following locations were searched:

相关标签:
14条回答
  • 2020-12-02 15:37

    If you've checked all the things from the above answers (which are common mistakes) and you're sure that your view is at the location in the exceptions, then you may need to restart Visual Studio.

    :(

    0 讨论(0)
  • 2020-12-02 15:38

    Check the build action of your view (.cshtml file) It should be set to content. In some cases, I have seen that the build action was set to None (by mistake) and this particular view was not deploy on the target machine even though you see that view present in visual studio project file under valid folder

    0 讨论(0)
  • 2020-12-02 15:41

    If the problem happens intermittently in production, it could be due to an action method getting interrupted. For example, during a POST operation involving a large file upload, the user closes the browser window before the upload completes. In this case, the action method may throw a null reference exception resulting from a null model or view object. A solution would be to wrap the method body in a try/catch and return null. Like this:

    [HttpPost]
    public ActionResult Post(...)
    {
        try
        {
            ...
        }
        catch (NullReferenceException ex)  // could happen if POST is interrupted
        {
            // perhaps log a warning here
            return null;
        }
    
        return View(model);
    }
    
    0 讨论(0)
  • 2020-12-02 15:45

    I had this same issue. I had copied a view "Movie" and renamed it "Customer" accordingly. I also did the same with the models and the controllers.

    The resolution was this...I rename the Customer View to Customer1 and just created a new view and called it Customer....I then just copied the Customer1 code into Customer.

    This worked.

    I would love to know the real cause of the problem.

    UPDATE Just for grins....I went back and replicated all the renaming scenario again...and did not get any errors.

    0 讨论(0)
  • 2020-12-02 15:48

    I came across this error due to the improper closing of the statement,

    @using (Html.BeginForm("DeleteSelected", "Employee", FormMethod.Post))

    {

    } //This curly bracket needed to be closed at the end.

    In Index.cshtml view file.I didn't close the statement at the end of the program. instead, I ended up closing improperly and ran into this error.

    I was sure there isn't a need of checking Controller ActionMethod code because I have returned the Controller method properly to the View. So It has to be the view that's not responding and met with similar Error.

    0 讨论(0)
  • 2020-12-02 15:49

    Problem:

    Your View cannot be found in default locations.

    Explanation:

    Views should be in the same folder named as the Controller or in the Shared folder.

    Solution:

    Either move your View to the MyAccount folder or create a HomeController.

    Alternatives:

    If you don't want to move your View or create a new Controller you can check at this link.

    0 讨论(0)
提交回复
热议问题