Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Xiaolong Yang4,374 Points
The name viewbag does not exist in the current context
When I was trying to copy and past the files into my project, as what the video said, the VS told me that something can't be copied (because of something about permission? can't recall...) I thought that might because some files were running, so I closed the VS and restarted it after the copy is finished. But then I found for some reason, both the Detail.cshtml and web.config are missing, and since I forgot to push the code, I couldn't get them back from github. I got back to the nearest version I could find, and redo the class step by step, but for some reason, when I move the properties to .cs file, and add ViewBag to cshtml, VS add a red line under every ViewBag, saying "The name viewbag does not exist in the current context". I have googled this problem, some said it's because the web.config is missing, but when I checked it, I found it's definitely there, not missing. Is there something I could do to solve the problem?
That sounds like a big mess. Just to be sure, it's referring to the web.config that's located in the views folder and not the one in the root folder. You might have to create a new project and copy the controllers, views, and models to the new project to fix the corruption.