Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am using a surface controller and it is working well for the forms. It even respects the authorize attribute I have applied to the controller (though this is due to child actions).
Layout = "_Layout.cshtml";
public class MyController : SurfaceController
public ActionResult Index()
//Todo: Redirect Logic
public ActionResult MyForm()
public ActionResult FormSubmit(myModel model)
I now however wish to add another check and redirect the user accordingly. I cannot do this inside the child actions and need to do this on the main call to the page.
I tried creating a method call index however it is never hit. I suspect the authorize attribute is only working as a child action is hit.
My Controllers are in a different assembly to the main site but I do not think this is an issue.
Could you please post the code you use to call your index method of your controller ?
I am just using navigating to the URL of the published page that has the same name as the surface controller and the template.
The code above is just sample code but it would be http://testdomain.com/My
Yeah you see, that will not work, Umbraco does not work that way, if you want to get hold of you index method you need to do this
@Html.Action("ActionName (Index)", "ControllerName (MyController)")
Where the things inside the parenthases are what your values should be.
Hope it makes sense :)
How can I redirect if some data is missing on a standard page or do I need to use an RenderMvcController instead.
If use the RenderMvcController then I do not have access to the methods needed for the form post.
Depends on where you want to redirect to if you just want to redirect back to the same page, you can use
and if you want to go to another Controller Method you can do
return RedirectToAction("ActionName", "ControllerName");
And to redirect to a different page you can use
return RedirectToUmbracoPage(the pages id here);
What I mean is if I change to use the RenderMvc Controller RedirectToCurrentUmbracoPage and simmilar methods are not available.
That is true, but SurfaceController derives from RenderMVCController i believe
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted