Umbraco SurfaceController 模型问题

Issue with Umbraco SurfaceController Model

我收到以下错误

System.InvalidOperationException: '传递到字典中的模型项是 'Umbraco.Web.Models.RenderModel' 类型,但是这个字典需要一个 'NewSite.Models.ContactModel2' 类型的模型项。'

我的模板如下

@using NewSite.Models
@{
    Layout = "Master.cshtml";
    Html.RenderPartial("~/Views/Contact/Contact.cshtml");
}

我的控制器如下

using NewSite.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Umbraco.Web.Models;
using Umbraco.Web.Mvc;

namespace NewSite.Controllers
{
    public class ContactController : SurfaceController
    {
        // GET: Contact
        [HttpGet]
        public ActionResult Index()
        {
            ContactModel2 cmodel = new ContactModel2();
            cmodel.Email = "ddddddaaaaa";
            return PartialView("ContactPartial",cmodel);
        }

        [HttpPost]
        public ActionResult HandleContact(ContactModel2 model)
        {
            if(!ModelState.IsValid)
            {
                return CurrentUmbracoPage();
            }
            ContactModel2 m = new ContactModel2();
            return RedirectToCurrentUmbracoPage();

        }


    }
}

我的部分观点如下

@model NewSite.Models.ContactModel2

@using (Html.BeginUmbracoForm("HandleContact", "Contact"))
{
    @Html.TextBoxFor(model => model.Email);
    <button name="BtnSubmit" type="submit">Submit</button>
}

我的模型如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Umbraco.Web.Models;

namespace NewSite.Models
{
    public class ContactModel2
    {
        public string Email { get; set; }
    }
}

我不知道为什么它认为我正在尝试向它传递 RenderModel...

我认为您需要将适当的模型传递给 .RenderPartial() 方法。

来自文档:

"When Html.RenderPartial() is called with just the name of the partial view, ASP.NET MVC will pass to the partial view the same Model and ViewData dictionary objects used by the calling view template."