VS2010 Ultimate, ASP.NET MVC 3 w/Razor.
I've created a custom view engine in my MVC3 app that allows nested areas, like so
~/areas/admin
/marketing
/views
index
/controllers
marketingController
/email
/views
index
...
/controllers
emailController
/templates
/views
index
edit
...
/controllers
templatesControler
etc.
This all works great, except for I seem to have lost intellisense in views that aren't in the standard ~/areas/area_name/views/myview.cshtml
location.
Any suggestions?
Update
Just on a lark, I added an @inherits statement
@inherits System.Web.Mvc.WebViewPage<Namespace.Models.Class>
and intellisense started working. I then deleted the statement, and it continues to work.
Is there some setting in the project file or something that tells Visual Studio what sort of intellisense to apply to an open file, other than the file extension? (If the extension was all that was used, I'd expect it to be a whole lot more consistent).
Update 2
While adding a web.config to each of my view folders fixes the problem quite nicely, putting the razor config in the root web.config doesn't.
After adding the required system.web.webPages.razor
section to ~/web.config
,
- I add a Razor .cshtml view file to one of my nested view folders.
- Intellisense works.
- I rename the file (keeping the .cshtml extension)
- Intellesense and syntax highlighting stop working.
- I close the renamed file and reopen it - everything starts working again.
- Or, instead of closing and reopening the file, I rename it back to its original name, it starts working again.
This feels like a VS bug - renaming a file (but keeping the proper extension) shouldn't, as far as I can tell, cause this sort of behavior. I'll continue putting individual web.config
s in each of my view folders since it corrects the problem, but it's annoying to have to clutter up the solution when I'd expect these settings to propagate through the solution tree as other web.config settings do.
It's also worth noting that, no matter where the Razor config is located, the site continues to function correctly whether or not intellesense is working.
Solved
I was informed (incredibly quickly) by the Powers That Be that this was a known issue that is corrected in MVC3 RTM and VS2010 SP1. The issue disappeared after updating my MVC3 installation and adding SP1.