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

前端 未结 14 2152
挽巷
挽巷 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:56

    I got this error because I renamed my View (and POST action).

    Finally I found that I forgot to rename BOTH GET and POST actions to new name.

    Solution : Rename both GET and POST actions to match the View name.

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

    In my case, I needed to use RedirectToAction to solve the problem.

    [HttpGet]
    [ControleDeAcessoAuthorize("Report/ExportToPDF")]
    public ActionResult ExportToPDF(int id, string month, string output)
    {
        try
        {
            // Validate
            if (output != "PDF")
            {
                throw new Exception("Invalid output.");
            }
            else
            {
                ...// code to generate report in PDF format
            }
        }
        catch (Exception ex)
        {
            return RedirectToAction("Error");
        }
    }
    
    [ControleDeAcessoAuthorize("Report/Error")]
    public ActionResult Error()
    {
        return View();
    }
    
    0 讨论(0)
提交回复
热议问题