没有为此对象定义的无参数构造函数。 (Debug永远不会到达任何控制器动作?)

时间:2016-06-10 22:05:05

标签: asp.net-mvc asp.net-core-mvc

我讨厌这些错误。

我有一个ASP.NET Core MVC表单。当我提交表单时,我得到了为这个对象定义的可怕的无参数构造函数。"错误。

我似乎无法点击调试器中的任何内容来帮助我找到出错的地方。

我的控制器:

using Brand.Extensions;
using Brand.Models;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Brand.Controllers
{
    public class ContentController : Controller
    {

        public IActionResult Index()
        {
            return View();
        }

        [HttpGet]
        public IActionResult Upload()
        {
            return View();
        }

        [HttpPost]
        [ValidateAntiForgeryToken]
        public IActionResult Upload(UploadedContentModel uploadedContentModel, FormCollection formCollection, IFormFileCollection uploadedFiles)
        {
            ContentExtensions contentExtensions = new ContentExtensions();
            FileExtensions fileExtensions = new FileExtensions();
            FileModel file = new FileModel();
            file = fileExtensions.GetFileModel(uploadedFiles["File"]);
            uploadedContentModel.File = fileExtensions.UploadFile(file).ID;

            FileModel thumbnail = new FileModel();
            thumbnail = fileExtensions.GetFileModel(uploadedFiles["Thumbnail"]);
            uploadedContentModel.Thumbnail = fileExtensions.UploadFile(thumbnail).ID;

            uploadedContentModel.ID = contentExtensions.UploadContent(uploadedContentModel).ID;

            return View();
        }
    }
}

我的模特:

public class UploadedContentModel
{
    public Guid ID { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public Guid File { get; set; }
    public Guid Thumbnail { get; set; }
    public string ContentType { get; set; } 
    public string Solutions { get; set; }
    public string Industries { get; set; }
    public string AdditionalTags { get; set; }
    public DateTime Publish { get; set; }
    public DateTime Expire { get; set; }
    public string AuthorizedRoles { get; set; }
    public string Author { get; set; }
    public DateTime Created { get; set; }
}

0 个答案:

没有答案