Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
I would rather use the @Html.ActionLink if you want to create a link to a method in a controller and pass data to it.
Same goes for redirect I would use: RedirectToAction("Index", "NewController");
Regarding routing in Episerver vs MVC, I think this is a good blog post: http://jondjones.com/learn-episerver-cms/episerver-developers-guide/episerver-routing/episerver-7-routing-for-dummies
url of incoming request does not guarantee that particular page controller will be hit. imagine that you can create zillions of instances of that particular page (content) type under the start page: /page1/, /page2/, /page3/ etc. so how episerver knows that request to all these 3 url should invoke exactly the same page controller? it does by not direct mapping of url to page type but instead actually "looks" who is sitting under that url (what content type) and then does black magic with resolving which handler will be invoked (because there might be complex inheritance chain between the types). so it's not 1:1.
I solved it using node like this
@Url.Action("RemoveBookmark", new { node = Model.CurrentPage.ContentLink, id = i.Id.ToString() })
So I have a controller like this
public class BookmarksPageController : PageController
{
public ActionResult Index(BookmarksPage currentPage)
{
/* Implementation of action. You can create your own view model class that you pass to the view or
* you can pass the page type for simpler templates */
IEnumerable bookmarksFolders = BookmarksFolder.GetFoldersByEmail();
var model = new BookmarksPageViewModel(currentPage, bookmarksFolders);
return View(model);
}
public ActionResult RemoveBookmark(BookmarksPage currentPage)
{
// I want to do something here and redirect to the Index action
return Redirect("/en/bookmarks");
}
}
The issue is that my currentPage in RemoveBookmark action is always null.
I am calling it this way
I think it is because it is routing like mvc and not through the episerver routing. How to solve this?
Ideally I would like to have currentPage in RemoveBookmark action to be not null but if that is not possible I would at least like to throw user to the Index properly so that I don't have to hard code the url like Redirect("/en/bookmarks");