简体   繁体   中英

NHaml configuration problem: Model is not found

I'm having a little problem with my NHaml config:

<configSections>
    <section name="nhaml" type="NHaml.Configuration.NHamlConfigurationSection, NHaml"/>
</configSections>

<nhaml AutoRecompile="true">
  <assemblies>
    <add assembly="Microsoft.Web.Mvc"/>
    <add assembly="MyAssembly"/>
  </assemblies>
  <namespaces>
    <add namespace="NHaml.Web.Mvc"/>
    <add namespace="MyAssembly.Models"/>
    <add namespace="System.Linq"/>
  </namespaces>
</nhaml>

The problem is that I'm trying to use a model from MyAssembly.Models in my view:

%ul
  - foreach(var v in (IQueryable<Model>)ViewData["stat"])
    %li= v.name

But it keeps crashing, telling me that MyAssembly.Models.Model is not recognized, and asking me if I'm lacking a using directive. Is there anything wrong in my web.config or my view?

Thanks in advance.

我没有使用过NHaml,因为它是MvcContrib的一部分,但是那时我通过在配置中指定完整的程序集名称来使自己的模型工作,例如:

MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM