Problems to be aware of when using the MVC Framework (4): ActionLink only performs Get operations

Source: Internet
Author: User
Tags actionlink
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 ");}
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.