November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
For the first question - can you post view code as well?
For second question - in EPiServer page controllers usually are used to to serve incoming requests for page instances. So for example if you have page Page1 and it has coresponding page controller and editor created 2 pages with this page type:
Root -> Start Page -> Page1 type instance 1st
Root -> Start Page -> Page1 type instance 2nd
Question is - to which page instanc you want to redirect? I would assume that maybe you want to store PageReference property in some particular page type and use that as content reference to get page's url and then make a redirect.
For instance: after submitting form you want to show "Thank You page" (code could be something like this - in controller method):
var resultPageReference = currentPage.ThankYouPage;
var urlResolver = ServiceLocator.Current.GetInstance<UrlResolver>();
var contentLoader = ServiceLocator.Current.GetInstance<IContentLoader>();
var resultPage = contentLoader.Get<SitePageData>(resultPageReference);
var pageUrl = urlResolver.GetVirtualPath(resultPage.ContentLink);
Current page could be resolved using some helper methods (assumig that you are inheriting from PageControllerBase - in AlloyTech MVC sample project):
protected T GetPage()
{
var pageRouteHelper = ServiceLocator.Current.GetInstance<PageRouteHelper>();
return pageRouteHelper.Page as T;
}
Question 1:
You typically make one controller per page type in episerver 7 with mvc.
Consider this:
Question 2:
I suggest you avoid trying to redirect to controller actions directly if you are not within the same controller. More on that later. If you want to redirect to another controller than the one serving your current page request, my guess is that you actually want to redirect to another page instance in the CMS. If you have a wizard like page with several steps and you would like to post data between steps, that would work just fine:
This works fine, and you can get unique URLs for every step. The guys handling your web site tracking will like that.
If you would like to return a RedirectResult pointing to an action, this works just fine if you are within the same controller.
In your login case:
Hi, I'm new to EPiServer MVC but have worked on some simple MVC projects before. I'm stumbeling to get some of the usuall MVC-functionallity to work and have 2 questions :).
Question #1:
One of these project had an LogOn controller (get) and a View that when submitting sent me to my LogOn controller (post). I can't get this to work in EPiServer, I'm sent to my LogOn(post) when submitting but the model is always null..
What am I missing?.
[HttpPost]
public ActionResult LogOn(LogOnModel model, string returnUrl)
{
// Empty model..
}
And question #2:
Is it possible to RedirectToAction in EPiServer mvc?. I can only get this to work if I redirect to a controller action in the same controller as the Redirect-statement... (I want to from ControllerA redirect to action in ControllerB).
RedirectToAction("Index", "SomeOtherController");