问题
Is it possible to use the Microsoft (or Mono) supplied System.Web.Routing instead of the MonoRail routing stuff when building a Castle MonoRail app for ASP.NET? Any good information on how to implement this as a solution? Pros and cons?
回答1:
It is quite possible. You should implement ASP.NET's IRouteHandler
that will look up the route data in the given RequestContext
, and then hand the data over to MonoRail.
That can be done is several ways. I guess that Server.RewritePath will work, but you can more cleanly lookup the code in two classes of MonoRail, namely MonorailHttpHandlerFactory
and RoutingModuleEx
, to figure out how to return set the needed things on the MonoRailHttpHandler
you'll return from the IRouteHandler
.
As for problems - it would be very tricky to to the reverse, i.e. generate routes from controller actions.
来源:https://stackoverflow.com/questions/3302345/is-it-possible-to-use-system-web-routing-in-castle-monorail