Question

I am building module to register customers and after registration i need to redirect the user to home page (default). I cant see a way as in Orchard everything works as content items.

Some of my code from Controller is given below

             $ if (!ModelState.IsValid)
            return new ShapeResult(this, _services.New.Checkout_Signup(Signup:  signup));

        var customer = _customerService.CreateCustomer(signup.Email, signup.Password);
        customer.FirstName = signup.FirstName;
        customer.LastName = signup.LastName;
        customer.Title = signup.Title;

        _authenticationService.SignIn(customer.User, true);

        return Redirect("~/Home Page URL here...");
Was it helpful?

Solution

In Orchard, the home page has an empty string for its alias. It's possible to look up the RouteValueDictionary of an alias by calling the IAliasService.Get() method. Once you have this, you can simply pass it to RedirectToRoute().

So for the home page:

var homepage = _aliasService.Get(String.Empty);
return RedirectToRoute(homepage);

You can see Orchard using this mechanism to check the home page in the AutoroutePartDriver.cs file lines 66 - 72 in version 1.7.2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top