ASP.NET 2.0 Profiles
Date: 06/23/06
(C Sharp) Keywords: database, web, hosting
I've got three questions.
One - on user profiles.
Two - on membership providers.
Three - on the correctness of my general approach.
So, here they go:
1) I wrote the following code in Page_Load:
string test_usr = "bush";
string test_pwd = "george"; // that's why pentagon gets hacked
string test_email = "bush@whitehouse.gov";
Membership.CreateUser(test_usr, test_pwd, test_email);
FormsAuthentication.Authenticate(test_usr, test_pwd);
Profile["uid"] = "43"; // Error: the property cannot be set for anonimous user
Profile["utype"] = "President";
Response.Output.Write(Profile["uid"] + " " + Profile["utype"]);
I pointed out an error in the comments above. I thought that once user is authenticated, it's assumed that I'm accessing him, when I use Profile. How do I do it properly? (Read a few articles, didn't find it.)
2) A Membership Provider has the connection string, which tells authentication system where to store everything. Well, I went to that weird directory deep in VS.NET folders, and found the default provider, and edited it. Now membership works with my remote db properly. But, will it work when I move it to the website hosting? Doesn't seem to me that that file I edited will move along with the website. What do I do then?
This is an approach question, if you have some time. :)
3) We have a database of clients' data. This database, however, has no authentication fields, like passwords, usernames, and so on. I decided that authentication should be implemented separately, using Membership Providers. I've prepared a separate database for that purpose, edited the Provider, and tables were created perfectly. So I thought, I'm gonna use the User Profiles in order to store the client's id in the authentication database, which is the same id as the one stored in the client data db. This way I'm kind of connecting the two databases together. There are a couple of reasons I'm doing it. First - if I was to put all the data into User Profiles, without using separate database, it'd be slow and ineffective. Second - some clients are already in the database before they even registered on the website. (database is created independently of them). Therefore, if they do register, all I would need to do, is bind their authentication info to their actual data in the other database. Is this a good approach for the whole thing?
Another long post, I know. Thanks for all the help so far!
Source: http://community.livejournal.com/csharp/67218.html