Не уволил методом при использовании интерфейса
I have using Asp.net web api and the method calling another Class library which is working fine. For implementing Redis cache, I changed to class to interface. In this case the method is not fired which is in class library. I am getting the below error "Object reference not set to an instance of an object.","ExceptionType":"System.NullReferenceException","StackTrace"
Что я уже пробовал:
public class ArticleListingController : ApiController { public IArticleProvider _newsarticleProvider { get; set; } [HttpGet] [Route("Listing")] public IHttpActionResult GetArticlesListing(string sectionName, int RegionId, int Count) { List<Article> articleList = new List<Article>(); if (!string.IsNullOrEmpty(RegionId.ToString())) { if (articleList != null) { articleList = _newsarticleProvider.GetArticleListBySectionName(sectionName, RegionId, Count, ListingArticleCache); return Ok(articleList); } } return NotFound(); } } In Provider Interface Code public interface IArticleProvider { List<Article> GetArticleListBySectionName(string sectionName, int RegionId, int Count, int CacheTime); } In Provider code public class ArticleProvider { public List<Article> GetArticleListBySectionName(string sectionName, int RegionId, int Count, int CacheTime) { return _articleRepositary.GetArticleListBySectionName(sectionName, RegionId, Count, CacheTime); } }
gbalamurugan
Я получаю нулевую ошибку ссылки в следующей строке
articleList = _newsarticleProvider.GetArticleListBySectionName(sectionName, RegionId, Count, ListingArticleCache);