The view 'Index' or its master was not found

前端 未结 9 1436
南方客
南方客 2020-12-03 16:03

I\'m new to the C# MVC project type and when I created an empty C# MVC project, I noticed the following error:

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


        
9条回答
  •  我在风中等你
    2020-12-03 16:21

    When a view is returned, it expects that an associated .cshtml file is in the same view folder structure as the controller layout for that area (if no areas are in use, then there is only 1 view folder and 1 controller folder). The controller name will be the folder name in the views folder, and the actionresult name will be the expected name of the .cshtml file.

    Luckily there is an easy way to remedy the situation where the view file is missing. Right click on Index for your action result, and then select Add View. Click okay, and it will create Index.cshtml for you inside of the correct folder. Now when you run the project, and navigate to Index, that is what you will see.

提交回复
热议问题