RazorGenerator can't see custom cshtml helper

前端 未结 5 2159
小鲜肉
小鲜肉 2021-02-12 20:06

I\'m having a problem with RazorGenerator: it can\'t compile views that uses my custom helper:

App_Code/ViewHelper.cshtml

@helper test(System.Web.Mvc.Ht         


        
5条回答
  •  情话喂你
    2021-02-12 21:01

    I had the same problem with RazorGenerator when I updated to MVC 5.

    According to this discussion on RazorGenerator's codeplex, it seems that the RazorGenerator.MsBuild package sometimes has a problem resolving the correct version of Razor to use, so ends up missing the namespaces defined in the web.config.

    To force it to use the correct version of Razor (and hopefully pick up your namespaces), create a file called razorgenerator.directives in the project folder containing the text: RazorVersion: 3

提交回复
热议问题