diff --git a/src/FubuMVC.Core/Http/AspNet/AspNetCurrentHttpRequest.cs b/src/FubuMVC.Core/Http/AspNet/AspNetCurrentHttpRequest.cs index d8f3ce31c0..ff31674603 100644 --- a/src/FubuMVC.Core/Http/AspNet/AspNetCurrentHttpRequest.cs +++ b/src/FubuMVC.Core/Http/AspNet/AspNetCurrentHttpRequest.cs @@ -36,9 +36,9 @@ public string ToFullUrl(string url) url = "~/" + url.TrimStart('/'); } + var absoluteUrl = VirtualPathUtility.ToAbsolute(url); - - return VirtualPathUtility.ToAbsolute(url).TrimEnd('/'); + return (absoluteUrl != "/") ? absoluteUrl.TrimEnd('/') : absoluteUrl; } public string HttpMethod() diff --git a/src/FubuMVC.HelloSpark/Controllers/Air/AirController.cs b/src/FubuMVC.HelloSpark/Controllers/Air/AirController.cs index 802b4c961d..41725b7798 100644 --- a/src/FubuMVC.HelloSpark/Controllers/Air/AirController.cs +++ b/src/FubuMVC.HelloSpark/Controllers/Air/AirController.cs @@ -1,10 +1,12 @@ -namespace FubuMVC.HelloSpark.Controllers.Air +using FubuCore; + +namespace FubuMVC.HelloSpark.Controllers.Air { public class AirController { - public AirViewModel TakeABreath() + public AirViewModel TakeABreath(AirRequest request) { - return new AirViewModel { Text = "Take a breath?" }; + return new AirViewModel { Text = "Take a {0} breath?".ToFormat(request.Type) }; } public BreatheViewModel Breathe(AirInputModel model) @@ -17,6 +19,16 @@ public BreatheViewModel Breathe(AirInputModel model) } } + public class AirRequest + { + public AirRequest() + { + Type = "deep"; + } + + public string Type { get; set; } + } + public class AirInputModel { public bool TakeABreath { get; set; } diff --git a/src/FubuMVC.HelloSpark/HelloSparkRegistry.cs b/src/FubuMVC.HelloSpark/HelloSparkRegistry.cs index 780cd7a9db..062ad35d5e 100644 --- a/src/FubuMVC.HelloSpark/HelloSparkRegistry.cs +++ b/src/FubuMVC.HelloSpark/HelloSparkRegistry.cs @@ -22,7 +22,7 @@ public HelloSparkRegistry() ApplyHandlerConventions(); Routes - .HomeIs(c => c.TakeABreath()) + .HomeIs() .IgnoreControllerNamespaceEntirely() .IgnoreMethodSuffix("Command") .IgnoreMethodSuffix("Query") diff --git a/src/FubuMVC.HelloSpark/Shared/Application.spark b/src/FubuMVC.HelloSpark/Shared/Application.spark index bdb5077d07..681af3c5e1 100644 --- a/src/FubuMVC.HelloSpark/Shared/Application.spark +++ b/src/FubuMVC.HelloSpark/Shared/Application.spark @@ -17,5 +17,8 @@
no footer by default
+ +

You can always !{this.LinkTo().Text("go home")}. +

diff --git a/src/FubuMVC.Tests/Urls/UrlRegistryIntegrationTester.cs b/src/FubuMVC.Tests/Urls/UrlRegistryIntegrationTester.cs index 395db8960b..8490ff1571 100644 --- a/src/FubuMVC.Tests/Urls/UrlRegistryIntegrationTester.cs +++ b/src/FubuMVC.Tests/Urls/UrlRegistryIntegrationTester.cs @@ -43,7 +43,7 @@ public void SetUp() registry.ResolveTypes(x => x.AddStrategy()); - + registry.Routes.HomeIs(); graph = registry.BuildGraph(); @@ -63,6 +63,12 @@ public void retrieve_a_url_for_a_model_simple_case() { urls.UrlFor(new Model1()).ShouldEqual("http://server/fubu/one/m1"); } + + [Test] + public void retrieve_a_url_for_the_default_model() + { + urls.UrlFor(new DefaultModel()).ShouldEqual("http://server/fubu"); + } [Test] public void retrieve_a_url_for_a_inferred_model_simple_case() @@ -279,6 +285,11 @@ public void M5(Model3 input) [UrlRegistryCategory("different")] public void M4(UrlModel model) { } + + public string Default(DefaultModel model) + { + return "welcome to the default view"; + } } public class TwoController @@ -313,6 +324,7 @@ public class Model4{} public class Model5{} public class Model6{} public class Model7{} + public class DefaultModel { } public class ModelWithNoChain{} public class ModelWithoutNewUrl{}