문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top