Castle Monorail错误 - MonoRail无法解析模板'Articles \ List'的视图引擎实例

时间:2010-09-26 16:34:38

标签: castle-windsor castle-monorail

您好我正在尝试使用Castle Monorail实现我的第一个Web应用程序。

Nut我收到以下错误

MonoRail无法解析模板“Articles \ List”

的视图引擎实例

这是我的控制器

[Layout("Default"), Rescue("GeneralError")]
    public class ArticlesController : SmartDispatcherController
    {       
        public void List()
        {
            PropertyBag["articles"] = Article.FindAll();
        }
    }    

和我的观点

<h3>Articles list</h3>

<p>
<a href="new.castle">Create new Article</a>
</p>

<table width="100%" border="1" cellpadding="2" cellspacing="0">
<tr>
    <th>Id</th>
    <th>Name</th>
    <th>Content</th>   
</tr>
#foreach($article in $articles)
<tr>
    <td align="center">$article.Id</td>
    <td align="center">$article.Name</td>
    <td align="center">$article.Content</td>
    <td align="center">
        <a href="edit.castle?id=${article.Id}">Edit</a> | 
        <a href="delete.castle?id=${article.Id}">Delete</a>
    </td>
</tr>
#end
</table>
在global.asax中的

我有以下

public void Application_OnStart()
        {
            RegisterRoutes(RoutingModuleEx.Engine);

            ActiveRecordStarter.Initialize(typeof(Article).Assembly, ActiveRecordSectionHandler.Instance);

            // If you want to let ActiveRecord create the schema for you:
            // ActiveRecordStarter.CreateSchema();


        }

        private static void RegisterRoutes(IRoutingRuleContainer rules)
        {
            rules.Add(new PatternRoute("root", "/")
                          .DefaultForController().Is("Home")
                          .DefaultForAction().Is("Index"));

            rules.Add(new PatternRoute("standard", "[controller]/[action]/[id]")
                          .DefaultForController().Is("Home")
                          .DefaultForAction().Is("Index"));

            rules.Add(new PatternRoute("articles", "[controller]/[action]/[id]")
                          .DefaultForController().Is("Articles")
                          .DefaultForAction().Is("List"));
        }


this is my web.config

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="monorail" type="Castle.MonoRail.Framework.Configuration.MonoRailSectionHandler, Castle.MonoRail.Framework" />
    <section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
  </configSections>

  <activerecord isWeb="true">

    <config>
      <add
          key="connection.driver_class"
          value="NHibernate.Driver.SqlClientDriver" />
      <add
          key="dialect"
          value="NHibernate.Dialect.MsSql2008Dialect" />
      <add
          key="connection.provider"
          value="NHibernate.Connection.DriverConnectionProvider" />
      <add
          key="connection.connection_string"
          value="Data Source=.;Initial Catalog=GigaWebSolution;Integrated Security=SSPI" />
      <add
          key="proxyfactory.factory_class"
          value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"  />
    </config>

  </activerecord>

  <monorail defaultUrlExtension="" useWindsorIntegration="true" smtpHost="localhost">
    <viewEngine viewPathRoot="Views" customEngine="Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine, Castle.MonoRail.Framework.Views.NVelocity" />

    <url useExtensions="false"/>

    <controllers>      
      <assembly>GigaWebSolutionMVC</assembly>
    </controllers>
  </monorail>

  <system.web>
    <compilation debug="true">
      <assemblies>
        <add assembly="*" />
      </assemblies>
    </compilation>

    <authentication mode="Windows"/>

    <customErrors mode="RemoteOnly" />

    <httpHandlers>
      <add verb="*" path="*.rails" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework" />
      <add verb="*" path="*.vm" type="System.Web.HttpForbiddenHandler" />
    </httpHandlers>

    <httpModules>
      <add name="routing" type="Castle.MonoRail.Framework.Routing.RoutingModuleEx, Castle.MonoRail.Framework" />
    </httpModules>
  </system.web>

</configuration>

任何建议?

由于

1 个答案:

答案 0 :(得分:0)

您的目录布局是什么?您的视图文件在哪里?

Monorail正在寻找您查看文件:

{project root}\Views\Articles\List.vm

此外,您不需要添加“文章”路线,因为“​​标准”路线就足够了。如果要为控制器定义默认操作,请使用DefaultAction属性。

    public class ArticlesController : SmartDispatcherController
    {
        [DefaultAction]
        public void List()
        {