Umbraco httppost错误:“未为此对象定义无参数构造函数”

时间:2019-06-07 17:04:03

标签: umbraco

我想将模型发送给HomePost控制器的动作,我拍摄了UmbracoForm和曲面控制器,当我运行它并单击“提交”时,出现错误:“没有为此对象定义无参数的构造函数”。

ViewModel:

 namespace Umbraco12.Models
    {
        public class Home : RenderModel
        {
            public Home(IPublishedContent content, CultureInfo culture) : base(content, culture)
            {
            }

            public string Topic { get; set; }
        }
    }

控制器:

public class HomeSurController : SurfaceController
    {
        // GET: HomeSur
        [HttpPost]
        public ActionResult HomePost(Home model)
        {

            //Do some stuff here, then return the base method
            return View("Home", model);
        }
    }

查看:

@inherits Umbraco.Web.Mvc.UmbracoViewPage<Umbraco12.Models.Home>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
    Layout = "Master.cshtml";
    }
   @using (Html.BeginUmbracoForm("HomePost", "HomeSur", System.Web.Mvc.FormMethod.Post, new { @class = "YourclassName" }))
    {
    <table cellpadding="0" cellspacing="0">
        <tr>
            <th colspan="2" align="center">Person Details</th>
        </tr>
        <tr>
            <td>@Umbraco.Field("topic")</td>
            <td>
                @Html.TextBoxFor(m => m.Topic)
            </td>
        </tr>

        <tr>
            <td></td>
            <td><input type="submit" value="Submit" /></td>
        </tr>
    </table>
    }

0 个答案:

没有答案