ASP.NET MVC3 Razor - lost intellisense when placing view in alternate location? -


vs2010 ultimate, asp.net mvc 3 w/razor.

i've created custom view engine in mvc3 app allows nested areas, so

~/areas/admin     /marketing         /views             index                /controllers             marketingcontroller         /email             /views                 index                 ...             /controllers                 emailcontroller         /templates             /views                 index                 edit                 ...                               /controllers                 templatescontroler 

etc.

this works great, except seem have lost intellisense in views aren't in standard ~/areas/area_name/views/myview.cshtml location.

any suggestions?

update

just on lark, added @inherits statement

@inherits system.web.mvc.webviewpage<namespace.models.class> 

and intellisense started working. deleted statement, , continues work.

is there setting in project file or tells visual studio sort of intellisense apply open file, other file extension? (if extension used, i'd expect whole lot more consistent).

update 2

while adding web.config each of view folders fixes problem quite nicely, putting razor config in root web.config doesn't.

after adding required system.web.webpages.razor section ~/web.config,

  1. i add razor .cshtml view file 1 of nested view folders.
  2. intellisense works.
  3. i rename file (keeping .cshtml extension)
  4. intellesense , syntax highlighting stop working.
  5. i close renamed file , reopen - starts working again.
  6. or, instead of closing , reopening file, rename original name, starts working again.

this feels vs bug - renaming file (but keeping proper extension) shouldn't, far can tell, cause sort of behavior. i'll continue putting individual web.configs in each of view folders since corrects problem, it's annoying have clutter solution when i'd expect these settings propagate through solution tree other web.config settings do.

it's worth noting that, no matter razor config located, site continues function correctly whether or not intellesense working.

solved

i informed (incredibly quickly) powers that known issue corrected in mvc3 rtm , vs2010 sp1. issue disappeared after updating mvc3 installation , adding sp1.

the views folder contains web.config file sets default options razor views, including default base type , namespaces, custom host enables @model directive.

razor views in different folder won't inherit configuration.
need add configuration web.config in folder:

<system.web.webpages.razor>     <host factorytype="system.web.mvc.mvcwebrazorhostfactory, system.web.mvc, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" />     <pages pagebasetype="system.web.mvc.webviewpage">         <namespaces>             <add namespace="system.web.mvc" />             <add namespace="system.web.mvc.ajax" />             <add namespace="system.web.mvc.html" />             <add namespace="system.web.routing" />         </namespaces>     </pages> </system.web.webpages.razor> 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -