0

how can I pass an id through actionlink without this being shown through the url?

@Html.ActionLink("Edit", "Edit", new { id = item.Id}) |

The URL appears to me the next picture form:

http://localhost:49723/UsersAdmin/Edit?id=c070d5f8-57ce-4714-a3e7-2b293b1a3e12

was supposed to pass the parameter id to the edit page without which this was shown in the url.

Thanks in advance!

Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
  • 1
    thats the way its supposed to work. – Daniel A. White Aug 26 '14 at 15:19
  • I can't see how that is possible with `ActionLink`, as passing params in the url is by design. You may need to look into using ASP.NET MVC `Ajax.ActionLink` http://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxextensions.actionlink(v=vs.118).aspx – Jason Evans Aug 26 '14 at 15:19
  • 2
    You can't use a link to pass data outside of the query string. You will need to make a form and submit that form or use an AJAX call. – Ethan Turk Aug 26 '14 at 15:19
  • You could technically store the data in cookies or web storage, but that would be bad design. – Daniel Sanchez Aug 26 '14 at 15:38
  • And what would be the point of not showing it anyway? The user can always type it in the address bar. –  Aug 27 '14 at 00:03

1 Answers1

0

If you want to get a link in the end (i.e. ) then there is no way, because clicking on the link will make browser sent a GET request to a given URL and the only way to specify parameters is as part of the url.

If you still want to "hide" the id from the url, then make a POST request and send id in post body.

However I strongly do not recommend to go with POST, because it contradicts the HTTP requests convention where POST requests are for updating data.

Denis Shulepov
  • 381
  • 1
  • 6