Redirecting in Fubu

This is a very straight forward post, just a reminder of how do you redirect and transfer in FubuMVC.

Using the FubuDinner example, we have a registration page, and its GET action:

public RegisterModel Query(RegisterModel input)
 input.PasswordLength = _settings.MinPasswordLength;
return input;

Now, in our POST method we’d like to log on the user and redirect to our Home page if the registration went ok (validated and persisted); however, if the registration wasn’t validated, we’d like to get back to our registration page, display the error messages and keep the data the user has entered.

This is how the POST method would look like than:

public FubuContinuation Command(RegisterForm input)
 var errors = _validator.Validate(input);

 //TODO: need unique username validation

 if( input.Nerd.Password != input.ConfirmPassword )
 errors.RegisterFailure("ConfirmPassword", "Confirm password must match password exactly.");

 if( errors.IsValid())
 _authContext.ThisUserHasBeenAuthenticated(input.Nerd.Username, false);
 return FubuContinuation.RedirectTo(new HomeModel());

 return FubuContinuation.TransferTo(new RegisterModel { Errors = errors, Nerd = input.Nerd, ConfirmPassword = input.ConfirmPassword });


Explore posts in the same categories: Fubu, MVC


You can comment below, or link to this permanent URL from your own site.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: