I've been spending the better part of two hours trying to figure this out. Here goes:
I just want to create an HTMLHelper extension method. This has been done many times before, and I know I'm coding it correctly. However, Razor only seems to know about it if I place the code file within App_Code (a folder which I thought no longer had meaning in the MVC world!)
How do I know this?
Quite simply...I have two identically-coded HTMLHelper extension methods in two separate identically-named files.
The first file, placed inside ~/Extensions contains the extension method DisplayForProperty
The second file, placed inside ~/App_Code contains the extension method DisplayForProperty2
When in a view, I type @Html.Displ
- Intellisense only shows me DisplayForProperty2
!
I do not have a @using
statement, as that does not appear to be necessary to see DisplayForProperty2
. Not to mention, it doesn't change anything in this case.
So, why is this? Should this even be happening this way? Is this just Razor being retarded, or am I the one being retarded?
I'm using a fully-updated copy of VS 2012.
PS - On another note, do I have to place the namespaces reference in every web.config under every /Views directory (as in, in every single Area), plus at the root? Why can't I just put this in the root or in the root /Views directory?