Question

I am trying to create a web site app using MVC 3- The problem is I want to setup a website where a user signs in they see data only specific to them. For example when you log into facebook, you only see your "wall" and not other peoples.

Can someone point me to a tutorial on how to setup a database where data can be connected to a user?

thanks in advance!

Was it helpful?

Solution

Have a table in your own data model that uses a primary key UserName. This is the value that will determine which wall you show to the user.

When a user registers, after you create them using the ASP.NET Membership Provider, add a new row to the Users table giving the same UserName as the UserName in the membership provider (for simplicity, we use email address for username -- easier to guarantee uniqueness). You can execute queries for their wall data by using the User property of the Controller class.

  1. User registers, you create a user account for them (Membership.CreateUser)
  2. At same time as Membership.CreateUser, insert UserName into a row on your data model
  3. User signs in
  4. User requests page
  5. Page uses the Controller.User property to query your app database for the correct wall content to display.

OTHER TIPS

I would suggest some of the tutorials over at asp.net/mvc. I am not sure if Nerd Dinner has been updated for MVC3 (a great tutorial by the way, written by Scott Guthrie), but it looks like the following tutorial has login functionality and explains at a basic level how to handle user specific data:

MVC3 Tutorial

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top