If you are using IIS7, you need to register the routing module in the system.webServer / httpModules node file.
System.web / httpHandlers and httpModules are not considered AFAIK IIS7.
MonoRail routing definitely works; we work happily. Here are the config and global.asax.cs snippets:
<system.web> <authentication mode="None" /> <compilation debug="true" /> <httpHandlers> <clear /> <add path="favicon.ico" verb="*" type="System.Web.StaticFileHandler"/> <add path="Trace.axd" verb="*" type="System.Web.Handlers.TraceHandler"/> <add path="*.config" verb="*" type="System.Web.HttpForbiddenHandler" /> <add path="*.spark" verb="*" type="System.Web.HttpForbiddenHandler" /> <add path="*.sparkjs" verb="*" type="System.Web.HttpForbiddenHandler" /> <add path="/content/**/*.*" verb="*" type="System.Web.StaticFileHandler" /> <add path="/content/**/**/*.*" verb="*" type="System.Web.StaticFileHandler" /> <add path="/content/**/**/**/*.*" verb="*" type="System.Web.StaticFileHandler" /> <add path="/content/**/**/**/**/*.*" verb="*" type="System.Web.StaticFileHandler" /> <add path="*" verb="*" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework" /> <add verb="*" path="*.castle" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework"/> </httpHandlers> <httpModules> <add name="routing" type="Castle.MonoRail.Framework.Routing.RoutingModuleEx, Castle.MonoRail.Framework" /> <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" /> </httpModules> <trace enabled="true"/> </system.web> <system.webServer> <handlers> <clear /> <add name="FavIcon" path="favicon.ico" verb="*" type="System.Web.StaticFileHandler"/> <add name="Trace" path="Trace.axd" verb="*" preCondition="integratedMode" type="System.Web.Handlers.TraceHandler"/> <add name="BlockConfig" path="*.config" verb="*" preCondition="integratedMode" type="System.Web.HttpForbiddenHandler" /> <add name="BlockSpark" path="*.spark" verb="*" preCondition="integratedMode" type="System.Web.HttpForbiddenHandler" /> <add name="BlockSparkJs" path="*.sparkjs" verb="*" preCondition="integratedMode" type="System.Web.HttpForbiddenHandler" /> <add name="content" path="/content/**/*.*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" /> <add name="content2" path="/content/**/**/*.*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" /> <add name="content3" path="/content/**/**/**/*.*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" /> <add name="content4" path="/content/**/**/**/**/*.*" verb="*" preCondition="integratedMode" type="System.Web.StaticFileHandler" /> <add name="castle" path="*" verb="*" type="Castle.MonoRail.Framework.MonoRailHttpHandlerFactory, Castle.MonoRail.Framework" modules="ManagedPipelineHandler" scriptProcessor="" resourceType="Unspecified" requireAccess="Script" preCondition="integratedMode,runtimeVersionv2.0" /> </handlers> <modules> <add name="routing" type="Castle.MonoRail.Framework.Routing.RoutingModuleEx, Castle.MonoRail.Framework" /> <add name="PerRequestLifestyle" type="Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule, Castle.MicroKernel" /> </modules> <validation validateIntegratedModeConfiguration="false" /> </system.webServer>
(Actually, we never worked on IIS6, but did it on the web-dev server - we have support since then, and I was told that it will work with * IIS6-level mapping with aspnet_isapi.dll - but to by that time, dev working with Win2003 was updated to something with IIS7 on it, so we did not try this)
protected virtual void RegisterRoutes(IRoutingRuleContainer engine) { engine.Add ( new PatternRoute(ThorController.CtlrHome, "/[controller]") .DefaultForController().Is(ThorController.CtlrHome) .DefaultForArea().Is(ThorController.AreaPublic) .DefaultForAction().Is(ThorController.ActionIndex) ); engine.Add ( new PatternRoute(ThorController.KeyDefault, "/<area>/<controller>/[action]/[id]") .DefaultForArea().Is(ThorController.AreaPublic) .DefaultForAction().Is(ThorController.ActionIndex) .DefaultFor(ThorController.KeyId).IsEmpty ); }
(the first route processes our application root)
(consts on our base class ThorController try to shorten string literals)
As an aside, does anyone know if there is a syntax for doing what we do with static file processing on a single line? Of course, you need to be better than our "decision"; -)
Peter Mounce
source share