I"m beginning to establish in ASP.NET once more and also I faced a tiny mistake within Visual Workshop. When making use of a couple of razor features, my.cshtml documents reveal mistakes. As an example "The name "ViewBag" does not exist in the existing context". Right here is a photo:

*

I am utilizing a trial task. You can locate the job right here: https://github.com/Wintellect/Angular-MVC-Cookbook/tree/master/BasicProject

I have actually browsed a number of various other strings and also the majority of recommend to upgrade the web.config data(s). These 2 config data are currently existing and also given that it"s a rather preferred trial I think it has actually all the called for arrangement in it. I have certainly browsed these config documents as well as they do undoubtedly consist of the recommended remedies.

Various other information:

I have actually currently utilized tidy & restore on the option however that transformed absolutely nothing. When I produce an entirely brand-new MVC job it does workMy close friend has the exact same issue and also we both utilize VS 2015 as well as Windows 10I can still run the application and also it does function.

Many thanks ahead of time.


c# asp.net-mvc visual-studio razor web-config
Share
Enhance this concern
Comply with
modified May 14 "17 at 14:21
Michjuh
asked Mar 28 "15 at 15:53
*

MichjuhMichjuh
1,06222 gold badges88 silver badges1010 bronze badges
10
|Program 5 much more remarks

20 Solutions 20


Energetic Oldest Votes
129
I had this concern in spite of having all the proper setup.

It ended up being some poor documents in the Part Cache, protecting against the Razor sights from acknowledging ViewBag, Design, and also HtmlHelpers. Removing these documents addressed the trouble (great variations of these documents were developed following time I opened up Visual Workshop).

The documents are situated below:

%LOCALAPPDATA%\ Microsoft \ VisualStudio \ 14.0 \ ComponentModelCacheDelete all 4 documents:

Microsoft.VisualStudio.Default.cacheMicrosoft.VisualStudio.Default.catalogsMicrosoft.VisualStudio.Default.errMicrosoft.VisualStudio.Default.external

I have actually ultimately seen the exact same problem on a number of various other designer makers as well as this solution promptly resolves it.


Share
Boost this response
Comply with
modified Jan 13 "18 at 2:45
*

jpmc26
24.5 k99 gold badges8181 silver badges134134 bronze badges
addressed Nov 13 "15 at 8:40
*

FentonFenton
214k6363 gold badges363363 silver badges376376 bronze badges
10
|Program 5 much more remarks
43
Update the variation numbers in the setups of the web.config data in the Sights folder.

If you have actually upgraded the MVC variation with nuget, must be:

Various other reliance variations may require to be upgraded as well. Assemble and also namespace problems in Sights for MVC items and also assistants are normally associated with ruined web.config data within the Sight folders.


Share
Boost this solution
Adhere to
responded to Apr 10 "15 at 20:36
*

Benjamin AndersonBenjamin Anderson
1,3261010 silver badges1515 bronze badges
8
|Program 3 much more remarks
23
Locate "web pages: Variation" in the appsettings and also upgrade it to variation 3.0.0.0. My web.config had

and also I upgraded it to


Share
Boost this response
Adhere to
responded to Jan 21 "16 at 14:10

*

Damian GreenDamian Eco-friendly
5,37611 gold badge2727 silver badges3333 bronze badges
5
Include a remark|
22
I unintentionally got rid of web.config from the Sights folder, assuming that it was unneeded. When I placed it back it began functioning.


Share
Boost this response
Adhere to
modified Mar 30 "20 at 21:41
Jordan Rieger
2,82433 gold badges2626 silver badges4646 bronze badges
addressed Nov 14 "17 at 16:04
InGeekInGeek
2,03222 gold badges2020 silver badges3535 bronze badges
0
Include a remark|
14
After attempting whatever imaginable, it ends up something had actually changed my System.Web.WebPages.Razor in/ Views/Web. Config from the appropriate CamelCase System.Web.WebPages.Razor to an all-lowercase system.web.webpages.razor which eventually was my death.

Wishing this might assist a few other inadequate spirit with this issue ...

For recommendation, this is the right entrance (for my circumstance)


Share
Boost this solution
Adhere to
addressed Dec 11 "15 at 6:53
jbwebtechjbwebtech
41455 silver badges1111 bronze badges
3
Include a remark|
6
Since the folder of sights must have it is very own internet config [i encountered this problem much more times as well as lastly i found that it took place [/p>
Share
Boost this response
Adhere to
responded to Nov 27 "17 at 13:26
hosam hemailyhosam hemaily
33144 silver badges1515 bronze badges
2
Include a remark|
5
Often it is inadequate to alter variation numbers in the setups of the web.config. This trouble happens due to the fact that Visual Workshop 2015 doesn"t have mvc4 tooling.

Service is to update your task to MVC 5. It entirely fixes the problem.You can obtain assist from this web page. It plainly describes it.

http://www.asp.net/mvc/overview/releases/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2

Incidentally Aesthetic Workshop group stated they will certainly include mvc4 assistance to Visual Workshop 2015 with the very first upgrade.


Share
Boost this response
Adhere to
responded to Aug 22 "15 at 21:40
BurkBurk
2,6221818 silver badges2424 bronze badges
Include a remark|
3
In my instance I had this concern occurring just on my computer just for one task. When opened up in VS2017 it was having this trouble, my task functioned penalty in VS2012 yet.

The primary concern for me right here was cache. My task was indicating the older cached variations of dll for Razor and also MVC and also it was not locating functions that were included more recent variations, such as ViewBag. ViewBag was included Razor variation 3, yet since I had Razor variation 2 cached it might not discover ViewBag (however it can discover various other things which existed in variation 2). Nonetheless, merely getting rid of cache like in the approved response did not repair my trouble. We needed to transform config documents to claim "utilize variation 3 rather than 2" for Razor and also "make use of variation 5 as opposed to 4" for MVC, then shutting VS, eliminating cache, as well as opening up task and also restoring. Then points obtained repaired. Below are a lot more thorough guidelines.

Right here is the series of modifications that aided me repair my issue:

In "Sights" folder"s Web.config modification all places where MVC variation is readied to 4.0.0.0 to 5.0.0.0 Razor variation is readied to 2.0.0.0 to 3.0.0.0

Right here are those lines in my situation:

... (notes: 1) your variations might be various, I am simply informing what required to be performed in my instance 2) I left out some things with "..." for brevity 3) also if you have MVC variation something like 5.3.2.0 you ought to still input 5.0.0.0, very same with Razor"s variation - input all nos in 3.0.0.0)

In primary config data (the one on top degree) modification web pages: variation from 2.0.0.0 to 3.0.0.0.

This adjustment possibly did not influence remedy however I"ll still state it. Make certain that "Sights" folder"s area has the precise very same materials as main.conifg data at the origin of the job, something like:

Ultimately, close VS. Remove all cache documents in %LOCALAPPDATA%\ Microsoft \ VisualStudio \ 14.0 \ ComponentModelCache (or whatever your appropriate course is) similar to it is recommended in (presently) approved response by Fenton. Likewise delete.scan documents, also if it is not stated because solution. When you are done, open VS, Tidy your task and also Restore it. Points needs to be functioning currently. It helped me.