I am new to ASP.Net and am building an MVC project in VS2013 I have the following actionResult

public ActionResult Index()
        {
            LaundryUsers db = new LaundryUsers();
            var users = db.Laundries.Where(u => u.UserId == WebSecurity.CurrentUserId);

            if (users == null)
            {
                return HttpNotFound();
            }

            return View(users);

        }

The result always throws a null exception but The data is in the table. When I do a break the userid is in the currentUserId. I am from a visual basic background on Desktop
apps. Thanks in advance

Hard to say. Code looks fine. I suggest you break on line 4 and check whether db.Laundries contains any value at all.

try something like...

int myCount = 0;
foreach (Laundries l in users)
{
    myCount+=1;
}
if (myCount==0)...

one man's opinion...a table name should be the singluar name of the object it represents, user instead of users. For variables use List instead of the plural form, userList instead of users.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.