This project is read-only.

Object Reference not set to an instance of an object

Topics: Business Logic Layer
Apr 6, 2011 at 10:06 PM

I have modified the static properties and methods of Post and Category to non-static. The purpose of doing this is that I am allowing users to view only their post on their logon. Everything is working good so far. I have overloaded the FillPosts() method of BlogEngine in the following way in the Post.cs file:

public List<Post> FillPosts()
            IPostService postService = new PostService();

            List pList = postService.GetBlogPostsByUserName(HttpContext.Current.User.Identity.Name);



So the fill post method gets the list of posts according to the currently logged on user. However, when I try to edit/delete a new post or add a new entry, it throws an exception, "Object reference not set to an instance of the object". Whenever these operation are being performed for some reason, HttpContext.Current.User is null. I am having hard time to find the problem with HttpContext coming null.

Does anyone have any idea?