这是我的代码,这里发现了这个错误" System.NullReferenceException:'对象引用未设置为对象的实例。'"这是运行时错误,_DefaultRepo显示为NULL。
public class DefaultController : Controller
{
// GET: Default
private readonly IDefautlRepository _DefaultRepo;
private readonly LoginRepository _Login;
public DefaultController()
{
}
public DefaultController(IDefautlRepository DefaultRepo, LoginRepository Login)
{
this._DefaultRepo = DefaultRepo;
this._Login = Login;
}
public ActionResult Index()
{
return View();
}
public JsonResult GetGroupId (string EmailId , string Password)
{
try
{
string _emailId;
string _password;
MT_UserDetails User= new MT_UserDetails();
_emailId = EmailId;
_password = Password;
User = this._DefaultRepo.GetGroupId(_emailId, _password);
Session["GroupId"] = User.GroupId;
}
catch (Exception e)
{
throw e;
}
return Json(false, JsonRequestBehavior.AllowGet);
}
}
}