Possible Duplicate:
ASP.NET MVC: No parameterless constructor defined for this objectHttpPost在ASP.Net MVC3 -
我工作的一個ASP.NET MVC3應用程序 「對該對象定義無參數的構造函數」。
我試圖使用[HttpPost]
來檢索信息,當用戶在窗體上輸入它時。
立足我做掉了「默認」空白ASP.Net項目的登錄腳本,我有以下幾點:
在我的控制器:
public ActionResult Ticket(int id)
{
Models.Ticket model = new Models.Ticket(id);
return View("Ticket", model);
}
[HttpPost]
public ActionResult Ticket(int id, MMCR.Models.Ticket model)
{
if (id != model.TicketNo)
{
return View("Error");
}
return View("Ticket", model);
}
並在視圖我有:
@using (Html.BeginForm()) {
<div>
<fieldset>
<legend>View Ticket Details</legend>
<div class="editor-label">
@Html.LabelFor(m=>m.Status)
</div>
<div class="editor-field">
@Html.DropDownListFor(m=>m.Status, Model.Status)
</div>
<p>
<input type="submit" value="Update" />
</p>
</fieldset>
</div>
}
(顯然是剔除重複的東西)。
然而,當我點擊按鈕,我得到一個錯誤:
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
任何人都可以就如何解決這一些建議嗎?
哪個對象缺少無參數構造函數?如果它是你自己的,那麼你可以在黑暗中進行刺探併爲其添加一個無參數的構造函數。 – 2012-03-25 18:14:24
堆棧跟蹤中沒有任何東西來自我的一個類。 :( – TZHX 2012-03-25 18:17:44
http://stackoverflow.com/q/1355464/102937 – 2012-03-25 18:19:47