Image 发布后模型未更新

Image 发布后模型未更新,image,post,model-view-controller,dropzone.js,modelstate,Image,Post,Model View Controller,Dropzone.js,Modelstate,我正在尝试拖放上传一个图像,然后在裁剪完相同的图像之后 到目前为止,我有一个名为Index的页面,它可以毫无问题地上传图像,但是在发布之后,它不会更新页面上的模型。我正在使用Html.helpers显示模型中的数据。我已尝试清除modelstate,但没有任何更改。我已经使用dropzone.js进行上传和裁剪,我已经准备好Jcrop了 型号: public class ImageModel { public string ImageUrl { get; set; } p

我正在尝试拖放上传一个图像,然后在裁剪完相同的图像之后

到目前为止,我有一个名为Index的页面,它可以毫无问题地上传图像,但是在发布之后,它不会更新页面上的模型。我正在使用Html.helpers显示模型中的数据。我已尝试清除modelstate,但没有任何更改。我已经使用dropzone.js进行上传和裁剪,我已经准备好Jcrop了

型号:

    public class ImageModel
{
    public string ImageUrl { get; set; }
    public string FileName { get; set; }
}

public class EditorInputModel
{
    public ImageModel Image { get; set; }
    public double Top { get; set; }
    public double Bottom { get; set; }
    public double Left { get; set; }
    public double Right { get; set; }
    public double Width { get; set; }
    public double Height { get; set; }

    public string Caption { get; set; }
}
行动:

 public ActionResult Index()
    {
        var model = new EditorInputModel();
        model.Image = new ImageModel();
        model.Image.ImageUrl = "";
        model.Image.FileName = "";
        return View(model);
    }

    [HttpPost]
    public ActionResult Index(EditorInputModel model)
    {

        var image = WebImage.GetImageFromRequest();
        if (image != null)
        {
            var filename = Guid.NewGuid().ToString("d");

            model.Image = new ImageModel();                
            model.Image.FileName = image.FileName;                
            model.Image.ImageUrl = string.Format("data:image/{0};base64,{1}",image.ImageFormat, Convert.ToBase64String(image.GetBytes()));


            model.Width = image.Width;
            model.Height = image.Height;
            model.Top = image.Height * 0.1;
            model.Left = image.Width * 0.9;
            model.Right = image.Width * 0.9;
            model.Bottom = image.Height * 0.9;
            ModelState.Clear();
        }
        return View(model);
    }
视图:

@model FileUploadTest1.Controllers.EditorInputModel
@{
ViewBag.Title=“Index”;
}
文件上传测试
@使用(Html.BeginForm(“Index”、“Home”、FormMethod.Post、new{enctype=“multipart/formdata”、@class=“dropzone”、id=“dropzoneForm”}))
{
}
@使用(Html.BeginForm(“Editor”,“Home”,FormMethod.Post,new{enctype=“multipart/formdata”,id=“cropView”,style=“display:none”}))
{    
@Html.HiddenFor(x=>x.Left)
@Html.HiddenFor(x=>x.Right)
@Html.HiddenFor(x=>x.Top)
@Html.HiddenFor(x=>x.Bottom)
@Html.HiddenFor(x=>x.Image.ImageUrl)
@Html.HiddenFor(x=>x.Image.FileName)
@模型。左;
锁定纵横比

@LabelFor(model=>model.Caption) @Html.TextBoxFor(model=>model.Caption,新的{@class=“form control”}) @Html.ValidationMessageFor(model=>model.Caption)

}您正在视图中调用controller.classname

  @model FileUploadTest1.Controllers.EditorInputModel
它必须是model.classname

  @model projectname.Models.classname
  @model projectname.Models.classname