ActionLink back button

11,317

Solution 1

It would probably be easier to just use javascript to send them back to the last page in their history (without creating a link to the specific page).

history.go(-1)

Solution 2

I will go for a ActionLink like

<%=Html.ActionLink("<< Back to News List", "Index")%>

because user can access News/Details/1 directly and if then you have a link that uses history.go(-1) or history.back() function it will not redirect it to the Index action

Share:
11,317
Cameron
Author by

Cameron

Updated on June 04, 2022

Comments

  • Cameron
    Cameron about 2 years

    I have an Index method that does double duty as showing a list of posts and a queried list of posts and can also have pages so you get urls like /News/Page/1 or /News?query=test

    When a user clicks through to a post at say News/Details/1 they get a simple ActionLink that takes them back to the list. BUT I want this link to take them back to the actual page they were on in terms of the paging or the query. How could I do this? I don't want to use the JavaScript history method. Here is my current ActionLink: <%=Html.ActionLink("<< Back to News List", "Index")%> and this is an example of the paging links: <%= Html.RouteLink("<< First Page", "NewsPaging", new { query = ViewData["query"], page = 0 })%>

    Thanks