public HttpPostedFileBase ProfileImage {get;组; }

时间:2015-11-19 03:30:45

标签: asp.net-mvc

我正在开发MVC用户Profile Image Uplaoder,我无法更新数据库显示以下错误,请给我一个解决方案?有什么遗失?

 Error  2   Inconsistent accessibility: property type 'eData.DataClases.Masters.HttpPostedFileBase' is less accessible than property 'Data.KdbContext.ProfileImage' C:\Users\Mad\Videos\Projects2015\eData\DataClases\Masters\MasterContext.cs  117 32  eData

模型

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using eData.DataClases.Masters;

namespace eData
{
   public class RegisterModel
    {
        [Required]
        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }

        public HttpPostedFileBase ProfileImage { get; set; }
    }
}

1 个答案:

答案 0 :(得分:2)

某处您定义了自定义HttpPostedFileBase类。大概是这样的:

namespace eData.DataClases.Masters
{
    private class HttpPostedFileBase
    {
        // implementation
    }
}

(或者internal代替private

由于您的HttpPostedFileBase类具有更严格的可见性(privateinternal),因此您无法将其用作public属性的类型:

public HttpPostedFileBase ProfileImage { get; set; }

这是因为遇到该属性的任何消费代码都无法知道该属性的类型

通常,修复方法是使类的可见性与属性匹配,或使属性的可见性与类匹配。 (制作课程public或相应地设置属性privateinternal。)但是,老实说,您甚至有HttpPostedFileBase的自定义实现这一事实是首先有点奇怪......