Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Current Fubu registry
using FubuMVC.Core;
namespace CharmSim.Controllers
{
public class HelpController
{
public HelpViewModel Start()
{
return new HelpViewModel { Title = "Hello from Controller! " };
}
public HelpViewModel SomethingElse(HelpInputModel input)
{
return new HelpViewModel { Title = "Hello from Controller! " + input.HelpId };
}
}
public class HelpInputModel
{
public HelpInputModel(string helpId)
{
HelpId = helpId;
}
[RouteInput]
public string HelpId { get; set; }
}
public class HelpViewModel
{
public string Title { get; set; }
}
}
public class CharmSimRegistry : FubuRegistry
{
public CharmSimRegistry()
{
IncludeDiagnostics(true);
Applies.ToThisAssembly();
Actions.IncludeClassesSuffixedWithController();
this.WithSparkDefaults();
Routes
.IgnoreControllerNamespaceEntirely()
.UrlPolicy<CharmSimUrlPolicy>()
.HomeIs<HelpController>(c => c.Start());
}
}
<viewdata model="CharmSim.Controllers.HelpViewModel" />
<content:title>Charms System simulator</content:title>
<content:header>Charms System simulator</content:header>
<h1>${Model.Title}</h1>
<a href="${this.Urls.UrlFor(new HelpInputModel("23"))}">bla</p>
<p>!{this.LinkTo(new HelpInputModel("fr")).Text("Go Here")}</p>
public class CharmSimUrlPolicy : IUrlPolicy
{
public bool Matches(ActionCall call, IConfigurationObserver log)
{
return call.HandlerType.Name.EndsWith("Controller");
}
public IRouteDefinition Build(ActionCall call)
{
var route = call.ToRouteDefinition();
route.Append(call.HandlerType.Name.RemoveSuffix("Controller"));
route.Append(call.Method.Name);
return route;
}
}
@flq

This comment has been minimized.

Copy link
Owner Author

@flq flq commented May 6, 2011

What's confusing is that the "HomeIs" works. But the Url policy doesn't seem to be called. No routes appear in "_fubu" diagnostics.

@jeremydmiller

This comment has been minimized.

Copy link

@jeremydmiller jeremydmiller commented May 6, 2011

Is your HomeController in the same assembly as your CharmSimRegistry?

@flq

This comment has been minimized.

Copy link
Owner Author

@flq flq commented May 6, 2011

Yes, it's all one assembly...but isn't it the behaviour you expect? The action I use as Home does not enter the UrlPolicy. This also happens in the HelloSpark app in fubu, I checked via /_fubu/routes

@jeremydmiller

This comment has been minimized.

Copy link

@jeremydmiller jeremydmiller commented May 6, 2011

The action matching should have hit the HomeController and added the two actions to the BehaviorGraph just fine. Yes, the CharmSimUrlPolicy should never hit the HomeController.Start method because it already has a Route (HomeIs adds a route with "" as the pattern). You should see the SomethingElse() in your _fubu/chains view

@flq

This comment has been minimized.

Copy link
Owner Author

@flq flq commented May 6, 2011

That's settled then, thanks for your time...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment