just taking my baby steps in the world of MVC and EPi. What is correct way to redirect from controller to another page provided that I have the redirection target as PageReference/PageData?
I was looking at RedirectToRoute but couldn't yet figure out how to resolve route for page from PageReference/PageLink?
Response.Redirect of course works but seemed to as not the most elegant solution? Or I am just making simple task too complicated?
Any advice appreciated!
Here is how we do it:
var pageReference = ???
var urlResolver = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<EPiServer.Web.Routing.UrlResolver>();
var pageUrl = urlResolver.GetVirtualPath(pageReference);
Look here for more information: http://joelabrahamsson.com/episerver-7-and-mvc-getting-the-url-for-a-page/
Great thanks this did the trick!