I cannot use RazorGenerator.MVC after upgrade to MVC 5.1.2


If I won't edit any view I don't have any issue.

But after edit, I cannot compile my project any more:

error CS0103: The name 'Styles' does not exist in the current context
error CS0103: The name 'Scripts' does not exist in the current context


msmolka wrote Apr 11 at 9:50 AM

Adding namespace to main web config is not helping, but after remove razor generator web site is working without issue.

msmolka wrote Apr 11 at 10:35 AM

After reverting back solution to version MVC 5.1.1 all is working again.
For some reason System.Web.Optimization; is not added to namespaces after upgrade.

titobf wrote Apr 13 at 4:47 AM

This issue is happening to me to. Please, look at the following discussion: https://razorgenerator.codeplex.com/discussions/459467. This in an old issue that has come back again

msmolka wrote Jun 2 at 2:58 PM

Looks working in newest version 2.2.3

titobf wrote Jun 2 at 7:40 PM

Still not working for me. Namespaces from ~/Views/Web.config are not imported.

titobf wrote Jun 9 at 5:20 AM

In a new web project it worked. I didn't figure out yet why in my older project it doesn't :/. Both projects have mvc 5.1.2

Ian1971 wrote Oct 9 at 10:14 AM

I have the same problem

fabrice wrote Nov 28 at 6:13 PM

No fix yet?

titobf wrote Nov 28 at 7:16 PM

I have solved this issue by dropping a file named "razorgenerator.directives" in the root of my website folder with the following content:

RazorVersion: 3

fabrice wrote Dec 1 at 4:16 PM

Thank you titobf. This works fine!
Is this documented somewhere?

titobf wrote Dec 1 at 7:31 PM

I've got that solution thanks to Ligos's comment in the following discussion: https://razorgenerator.codeplex.com/discussions/459467. I do not know if it is documented somewhere, but it should.