Surface controllers, actionlinks with a friendly URL
Hi,
Wondering if somebody could guide me in the right direction, I'm new to MVC and unsure on the umbraco surface controllers.
From one of my views I have a Html.ActionLink("Link Name", "ActionName", "Controller", new {some params})
In my surface controller
[HttpGet]
publicActionResult ActionName(Params...)
{
var model = newMyModel();
// initiate model memberreturn PartialView("PartialView", model);
}
[HttpPost]
[ValidateAntiForgeryToken]
publicActionResult ActionNamePost(MyModel model)
{
//model not valid, do not save, but return current umbraco pageif (!ModelState.IsValid)
{
return CurrentUmbracoPage();
}
// model valid, save the properties
SaveModel(model);
var content = Services.ContentService.GetById(model.ContentPageId);
TempData.Add("ThankYouMessage", content.GetValue("thankYouMessage").ToString());
TempData.Add("Success", "true");
//redirect to current page to clear the formreturn RedirectToCurrentUmbracoUrl();
}
// out put form
}
else
{
<divclass="wrapper">@Html.Raw(TempData["ThankYouMessage"])</div>
}
}
That's the gist of it, may be some typo's don't worry about them. My question(s) are
1: How can I can my URL to be friendly so it doesn't show umbraco/Surface/MyController/MyAction?params
2: When inspecting the html the action of the form is ActionName?params, I only really wanted this for the get to initialise my model I want the post to be ActionNamePost
3: If I call my post the same as the get, it works but when failing on validation and trying to return CurrentUmbracoPage(); it fails with
Can only use UmbracoPageResult in the context of an Http POST when using a SurfaceController form
Surface controllers, actionlinks with a friendly URL
Hi,
Wondering if somebody could guide me in the right direction, I'm new to MVC and unsure on the umbraco surface controllers.
From one of my views I have a Html.ActionLink("Link Name", "ActionName", "Controller", new {some params})
In my surface controller
is working on a reply...