7

I'm new to MVC and trying to achieve page redirection. User will click on "Sign-out" and should be redirected to the "sign-in" page.
Here is my code.

public ActionResult SignIn()
{
  if (Sitecore.Context.IsLoggedIn)
  {
    LogoutUser();
    return RedirectToRoute(MvcSettings.SitecoreRouteName, new { pathInfo = "/en/sign-in" });
  }
}

This method is invoked, but the page is redirected to "en/?f" and the message on page is

This domain is not configured for this service. Please add it to your account.

Should something be configured for routes or in web.config.

Using Sitecore 8.0 update 5

enter image description here

1 Answer 1

14

To do page redirection, simply do

return Redirect(url);

For a permanent redirect (e.g. for search engines), use

return RedirectPermanent(url);

Both of these return a RedirectResult which inherit from ActionResult.

To redirect to a Sitecore Item, do it the same way you always have.

var url = LinkManager.GetItemUrl(yourItem);
return Redirect(url);
1
  • Watch the logs when you do this. I've seen instances of "Cannot redirect after HTTP headers have been sent." errors. Aug 18, 2020 at 18:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.