【问题标题】:ASP.NET MVC5. Error code not allowing controller to be view in browserASP.NET MVC5。错误代码不允许在浏览器中查看控制器
【发布时间】:2020-04-30 09:03:46
【问题描述】:

无法让我的事件控制器在浏览器中显示。我收到错误消息,指出我的列名无效

SqlException:列名“城市”无效。 列名“状态”无效。

事件模型代码 公开课活动 { [钥匙] 公共 int EventsId { 获取;放; }

    [Required(ErrorMessage = "Title is requied")]
    [StringLength(50, ErrorMessage = "Title cannot be more than 50 characters")]
    public string EventTitle { get; set; }

    [StringLength(150, ErrorMessage = "Description should not exceed 150 characters")]
    public string EventDescription { get; set; }

    [Required]
    public DateTime EventStartTime { get; set; }

    [Required(ErrorMessage = "Start Date cannot be in the past")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0;MMdd/yyyy}")]
    public DateTime EventStartDate { get; set; }
    [Required]
    public DateTime EventEndTime { get; set; }

    [Required(ErrorMessage = "End date cannot be less than Start date")]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0;MMdd/yyyy}")]
    public DateTime EventEndDate { get; set; }

    public string City { get; set; }
    public string State { get; set; }
    public string EventType { get; set; }

    [Required]
    public string OrganizerName { get; set; }
    public string OrganizerContactInfo { get; set; }
    [Required(ErrorMessage = " Max tickets cannot be 0")]

    public int MaxTickets { get; set; }

    [Required(ErrorMessage = "Avaliable tickets cannot be 0")]
    public int AvaliableTickets { get; set; }

    public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
    {
        throw new NotImplementedException();
    }
}

} 这里

enter image description here

【问题讨论】:

    标签: asp.net-mvc


    【解决方案1】:

    缺少很多信息。我的猜测是您数据库中的 Events 表不包含 City 或 State 列。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-04-06
      • 2014-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多