Search code examples
vb.netasp.net-mvc-4razor-2

My Helpers.vbhtml file results in "Type 'ASP.global_asax' is not defined"


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?


Solution

  • 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.