Handling button click in ASP.NET MVC 2 RTM

Posted by Leniel Macaferi on Stack Overflow See other posts from Stack Overflow or by Leniel Macaferi
Published on 2010-03-14T23:20:27Z Indexed on 2010/03/14 23:25 UTC
Read the original article Hit count: 400

I have a View in which the user is able to upload a file to the server.

In this view I also have 2 buttons: one to Upload a file and other to Download the last file imported.

In my Controller I created 2 action methods: Import and Export.

How could I manage to redirect each button click to the proper action method in my Controller?

I have tried Html.ActionLink:

<%= Html.ActionLink("Upload", "Import", "OracleFile")%>
<%= Html.ActionLink("Download", "Export", "OracleFile")%>

Html.ActionLink didn't do the trick. The action links were taking me to the right Action methods but they were generating a GET request. This way Request.Files.Count = 0.

I need a POST request.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about button-click