ASP.Net MVC4 Root cshtml and “does not inherit from 'System.Web.WebPages.WebPage”

后端 未结 3 1109
花落未央
花落未央 2021-01-04 00:52

I have followed the answers provided by very similar posts as you will see in the step by step listed below.

  • Razor view Type does not inherit from 'Syst

相关标签:
3条回答
  • 2021-01-04 01:19

    Remove the web.config from your Views folder.

    As you're including Partial1.cshtml from that folder, it is also including the web.config from within there. And that web.config is saying that all pages must inherit from WebViewPage.

    0 讨论(0)
  • 2021-01-04 01:37

    I am a beginner to this, but one thing I did not realise is that cshtml pages are served through a controller, rather than by loading them directly.

    In combination with the above, I also had to set the following key to false in the web.config file:

    <add key="webpages:Enabled" value="false" />
    
    0 讨论(0)
  • 2021-01-04 01:42

    Do not delete the webconfig, is a very important file in your views!!!

    Instead, do this:

    Enable "View all Files" in the web project that is failing, and search for a file that seems correct but is not included in visual studio, and delete it. If it fails in your deployment folder, try to clean the folder as well, and re-deploy the site, you might have unnecesary files that might cause the same problem.

    In my case, at the root of the webproject I had an extra copy of _ViewStart.cshtml (excluded from the project), I deleted that file, and that did the trick.

    Hope it helps, let me know if this solve your problem as well.

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