0
我想在连续滑动后将模型传递给控制器。ASP.NET MVC将表中的对象传递给控制器?
这是我的代码不起作用。
<table class="table">
<tr>
<th>
<p>Sender</p>
</th>
<th>
<p>Subject</p>
</th>
<th>
<p>Received</p>
</th>
<th>
<p>HasAttachment</p>
</th>
<th></th>
</tr>
@foreach (var item in Model.Inbox) {
<tr class="mail-row" onclick="location.href = '@(Html.ActionLink ("", "MailViewer", "Profile", new { mail = item }, null))'">
<td>
@Html.DisplayFor(modelItem => item.Sender)
</td>
<td>
@Html.DisplayFor(modelItem => item.Subject)
</td>
<td>
@Html.DisplayFor(modelItem => item.Received)
</td>
<td>
@Html.DisplayFor(modelItem => item.HasAttachment)
</td>
</tr>
}
</table>
我试图使用Url.Action,但我只在URL中的对象类型,而不是实际的对象。
我尝试发送这个对象:
public class Mail
{
public string Sender { get; set; }
public string Subject { get; set; }
public DateTime Received { get; set; }
public bool HasAttachment { get; set; }
public string content { get; set; }
}
你只能用'Url.Action'发送原始数据类型。我会把你的对象所需的所有基本类型放到你的'Url.Action'中,然后在你的控制器中序列化这个对象。 – NotTelling
为什么不向控制器发送ID或主键,并在控制器中处理以发回模型。 – Shan
那么不可能通过http url传递一个对象? – Amsel