How do I solve a “view not found” exception in asp.net core mvc project

前端 未结 16 1945
梦毁少年i
梦毁少年i 2020-12-09 15:53

I\'m trying to create a ASP.NET Core MVC test app running on OSX using VS Code. I\'m getting a \'view not found\' exception when accessing the default Home/index (or any oth

相关标签:
16条回答
  • 2020-12-09 16:17

    In my case, the build action was somehow changed to Embedded resource which is not included in published files.

    Changing Embedded resource to Content resolves my issue.

    0 讨论(0)
  • 2020-12-09 16:19

    Im my case it simply was a "forget" error...
    I had the folder with view not named the same as the controller name.
    Renamed the folder to the correct name.. and works...

    0 讨论(0)
  • 2020-12-09 16:23

    FWIW, In our case we received this error when accessing localhost:<port>/graphql even though the View/GraphQL/Index.cshtml was in the right place. We got the error because wwwroot/bundle.js and wwwroot/style.js was mistakenly not initially committed, since our .gitignore included wwwroot. Discovered it by inspecting the network traffic and seeing it was these files giving the 404 and not the Index.cshtml itself.

    0 讨论(0)
  • 2020-12-09 16:25

    I am using VS2017. In my case there was the view file at the proper place (with the proper name). Then I remembered that I renamed it before, (and the VS somehow did not asked me if I wanna change all the references as usual). So I finally deleted the view, then I made it again, and this solved my problem.

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