SqlProfileProvider – can you use Profile.GetProfile() in a project?

I am attempting to use the SqlProfileProvider in an application and can’t seem to use it the way I want to. I would like to be able to simply call up a profile like this:

Profile p = Profile.GetProfile("naspinski");
p.Organization = "new_org";

but I can’t seem to find the correct way to use the GetProfile() that I seem to see scattered around the net. Is there a way to grab, read and modify profiles?

I am using it in MVC 3 and will not be actually logging in as the specific user, this will be pulling users from the db that are specified. Thank you.

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

To retrieve the profile:

var profile = ProfileBase.Create(HttpContext.Profile.UserName, true);

And here’s the MSDN documentation. And a nice blog post about custom profiles.

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply