0

I am using ASP.NET 4.0 WebApplication project

The following will save user name to my current.profile

System.Web.HttpContext.Current.Profile["UserName"] = userName

I would like to add a new profile named Company with the value 'MyCompany' to all users. It should be somthing like that:

for all users....
{
    System.Web.HttpContext["SpecificUser"].Profile["Company"] = "MyCompany"
}

How can i do it?

user829174
  • 6,132
  • 24
  • 75
  • 125

1 Answers1

0

You cannot access everyone's HttpContext, however, you could write it to each profile, assuming you know the user's profile user ID. If you don't have their user ID's handy, you may want to write it to the database directly via a stored procedure. The main point is you need to write it to the profile DB in order to share it for all users.

Community
  • 1
  • 1
Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • can you share an example how to edit a specific user's profile (reminding that this is WebApplication). thanks! – user829174 Aug 28 '12 at 11:44
  • A small example here: http://msdn.microsoft.com/en-us/library/ms151826.aspx. See the link I included; you don't need to use the profile as a strong type; I believe you can call `profile.SetValue("Company", "MyCompany")` and that would work. – Brian Mains Aug 28 '12 at 11:51