I have an MVC5 project that is currently installed in Release Configuration, and it works 100%. However, as soon as I switch the project configuration from Release to Debug, everything goes wrong ... even if I switch it back to Release mode, everything will still break. The only way to get the project to work again is to restore it from backup.
This is what happens. Firstly, when I start a project, I get the following error:
BC30451: 'ViewData' not declared. It may not be available due to its level of protection.
If I open any view in the project using Visual Studio 2013, I see that all views are flagged as errors, such as ViewData, Html, Url, etc.
When you refer to @Html or @ViewData in a view, it usually refers to the .Html and .ViewData properties of the view base class (WebViewPage). However, if I start typing "@Html". in any of the views, I can see in autocomplete that this refers to the System.Web.Webpages.Html namespace, and not to the WebViewPage.Html property. This is so: if the view does not inherit from the System.Web.Mvc.WebViewPage class.
Any guidance on where I can start looking for this fix, or why is this happening?
Edit Since no one answered, I have come a long way. I created a new MVC5 project, added all the packages through Nuget, and then just copied all my files from the old project to the new one, and now it works.
Can anyone understand what could be causing this? I do not want to repeat all these problems in the future if the project suddenly decides to stop working again.
Vipergti
source share