Using C# 6's using static syntax in MVC App_Code display helpers

好久不见. 提交于 2019-12-02 04:48:33

This is not possible in MVC5 but MVC6.

See code change for supporting using static in MVC6: https://github.com/aspnet/Razor/commit/1879ac642754b5f84e6055580e6fc60e13fa2100

I think I'm using mvc 5 and it's working for me. System.Web.Mvc.dll version 5.2.3.0

I'm running this in VS 2015 which uses c# 6.0. So it's either that or the version 5.2.3.0 that's doing it.

So the answer by Kevin it may not be 100% correct.

MVC 6 is not "stable" in a very broad sense of the word so we are using MVC5 atm.

Note that at first it didn't find my static reference, but there was no squiggly. After cutting and repasting the "@using static" line a few times it started working. I can navigate to definition on my static extension method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!