Domanda

I created the ASP.NET special folder called App_Code in my MVC project. I added a new file Helpers.vbhtml that will contain repeatedly-used razor code snippets.

Folder structure

Helpers.vbhtml

@Helper GetTime()
    @DateTime.Now
End Helper

But this results in the error Type 'ASP.global_asax' is not defined. (x2)

Error

Nothing seems to be affected - the application still compiles and runs. What's this error mean?

È stato utile?

Soluzione

This error is caused by a naming conflict; there is a namespace called System.Web.Helpers.

The problem appears to be VB.NET-specific. I can't reproduce the problem in C#.

Rename the .vbhtml file to Snippets.vbhtml or something else that won't cause a naming conflict.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top