SurfaceController: Return of URL that maintains ModelState
Which method is simplest (best practice) to maintain ModelState like with return CurrentUmbracoPage();
I want a return method in the surface controller that returns ModelState, but Redirect does not retain ModelState. This should be a normal scenario, but can't find equivalent option for return method. The url contains parameter and anchor so the string is correct (/turlister?partial=LoginForm#tab-1)
if (!ModelState.IsValid)
// return CurrentUmbracoPage (); <= ModelState is maintained
return Redirect(string.Format("{0}#tab-1", "/turlister?partial=LoginForm"));
Thanks for your reply. I actually get the correct url with string.Format("{0}#tab-1", "/turlister?partial=LoginForm"), and now I've also found a solution that works
SurfaceController: Return of URL that maintains ModelState
Which method is simplest (best practice) to maintain ModelState like with
return CurrentUmbracoPage();
I want a return method in the surface controller that returns ModelState, but Redirect does not retain ModelState. This should be a normal scenario, but can't find equivalent option for return method. The url contains parameter and anchor so the string is correct (
/turlister?partial=LoginForm#tab-1
)Hi Tom
I'm not sure that it's right way to handle url fragments - Redirect(string.Format("{0}#tab-1", "/turlister?partial=LoginForm"));
Maybe it's better to use return CurrentUmbracoPage (); and pass some value to client in the ViewData and use this data in js for scrolling the page to
What do you think? Is it a solution?
Thanks,
Alex
Thanks for your reply. I actually get the correct url with
string.Format("{0}#tab-1", "/turlister?partial=LoginForm")
, and now I've also found a solution that worksbase controller
ActionResult
Now I can validate fields as before, both on the client side and on the server side.
I found the solution here: https://stackoverflow.com/questions/658747/how-do-i-maintain-modelstate-errors-when-using-redirecttoaction
What is by the way best practice regarding where to put OnActionExecuted, because I intend to use the method in several controllers?
is working on a reply...