My Helpers.vbhtml file causes the "Type" ASP.global_asax "not defined"

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

Folder structure

Helpers.vbhtml

 @Helper GetTime() @DateTime.Now End Helper 

But this leads to a Type 'ASP.global_asax' is not defined. error Type 'ASP.global_asax' is not defined. (x2)

Error

Nothing seems to have changed - the application is still compiling and starting up. What does this error mean?

+6
source share
1 answer

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

The problem seems to be related to VB.NET. I can not reproduce the problem in C #.

Rename the .vbhtml file to Snippets.vbhtml or something else that will not cause a name conflict.

+7
source

Source: https://habr.com/ru/post/953606/


All Articles