ActionLink is a link string that only supports GET actions.
<% @ Page Title = "" Language = "C #" MasterPageFile = "~ /Views/Shared/Site. master "Inherits =" System. web. mvc. viewPage <IEnumerable <Web. models. photoListItem> "%> <asp: Content ID =" Content1 "ContentPlaceHolderID =" TitleContent "runat =" server "> download center </asp: Content> <asp: content ID = "Content2" ContentPlaceHolderID = "MainContent" runat = "server"> <% if (Model! = Null) {%> <% using (Html. BeginForm () {%>
<% = Html. ActionLink ("delete", "DeleteFromDownloadList", new {id = item. Path}) %>
</Td> </tr> <% }%> </table> <input type = "hidden" id = "FileList" name = "FileList" value = ""/> <br/> <input type = "submit" value = "download" id = "download"/> <% }%> <%} else {%> sorry, you have no download list <% }%> </asp: Content> <asp: content ID = "Content3" ContentPlaceHolderID = "head" runat = "server"> <script src = ".. /.. /js/private/DownloadPage. js "type =" text/javascript "> </script> </asp: Content>
Code in Controller
/// <Summary> /// remove a photo from the download list /// </summary> /// <param name = "id"> </param>/ // <returns> </returns> // [AcceptVerbs (HttpVerbs. post)] [Authorize] public ActionResult DeleteFromDownloadList (string id) {string profileKey = "DownloadList"; ProfileBase profile = ProfileBase. create (User. identity. name); Models. downloadList list = profile. getPropertyValue (profileKey) as Models. downloadList; if (list! = Null & list. Items! = Null) {list. items. remove (list. items. firstOrDefault (I => I. path. equals (id); profile. save ();} return RedirectToAction ("Download ");}