TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Krishna Kumar
NA
135
38.9k
InterFace And WebApi.. NullReference Exception
Nov 28 2016 3:11 AM
public interface ILoginManager
{
IEnumerable<HR_Login> GetLogins();
}
I have declared this methods in the interface and implemented in below class
class LoginManager : ILoginManager
{
private readonly ILoginRespository _loginRepository;
public LoginManager(ILoginRespository loginRepository)
{
_loginRepository = loginRepository;
}
public HR_Login Create(HR_Login login)
{
return _loginRepository.Create(login);
}
Now i am trying to access the method in webapi
private readonly ILoginManager _loginManager;
public LoginController()
{
}
public LoginController(ILoginManager loginManager)
{
this. _loginManager = loginManager;
}
[HttpGet, Route("logins")]
public HttpResponseMessage Get()
{
return Request.CreateResponse(HttpStatusCode.OK, _loginManager.GetLogins());
}
And when i complied this code... It is giving mr the Null Reference exception in the controller GET Method.
Reply
Answers (
4
)
Abstract class inheritance
Error while rin the window application in vs 2012