Asp.Net MVC中如果要通过ActionLink生成链接,传递参数可以通过下面的代码实现
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server"> <p> Click to update record: <%= Html.ActionLink("Update Item", "Update", new {Id=4}) </p> </asp:Content>
输出的连接如下
<a href="/Home/Update/4">Update Item</a>