Castle Monorail error - MonoRail could not resolve a view engine instance for the template 'Articles\List'
Hi I am trying to implement my first web application using Castle Monorail.
Nut I am getting the following error
MonoRail could not resolve a view engine instance for the template 'Articles\List'
this is my controller
[Layout("Default"), Rescue("GeneralError")]
public class ArticlesController : SmartDispatcherController
{
public void List()
{
PropertyBag["articles"] = Article.FindAll();
}
}
and my view
<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开发者_StackOverflow社区">$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>
in the global.asax I have the following
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>
any suggestion?
Thanks
What is your directory layout and where are your view files?
Monorail is looking for you view file at:
{project root}\Views\Articles\List.vm
Also, you don't need to add the "articles" route as the "standard" route will suffice. If you want to define a default action for a controller use the DefaultAction attribute.
public class ArticlesController : SmartDispatcherController
{
[DefaultAction]
public void List()
{
精彩评论