How can I access web.config profile properties in ASP.NET 4.5?

I am looking at an ASP.NET 4.0 online course, just one of the first lessons.

I have Visual Studio 2012 for the Internet installed and it has ASP.NET 4.5.

To access some of the properties of web.config, the guy in the know writes the following line:

Profile.Preferences.MyParameter = "MyValue";

but when I type the same thing, it gives me an error: . And when I try to access , he says that . Profile element doesn't exist in the current contextSystem.Web.Profile.Preferences Type or namespace "Preferences" is missing in System.Web.Profile

Can anyone tell what is going on? Is ASP.NET 4.5 the cause of this behavior, and if so - how can I access the same web.config properties, is ASP.NET 4.5?

My web.config looks like this:

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <profile>
      <properties>
        <group name="Preferences">
          <add name="MyParameter"/>
        </group>
      </properties>
    </profile>
  </system.web>
</configuration>

UPDATE: I tried to execute the second solution from Joel Spolsky's answer: How to assign profile values?

. :

static public AccountProfile CurrentUser
    {
        get { return (AccountProfile)
                     (ProfileBase.Create(Membership.GetUser().UserName)); }
    }

, Memberhip.GetUser() null. ?

+3
1

, , , , .

, : ?

, - ? Visual Studio : " -" " -". , "-".

. , Windows app.config - web.config. web.config , ?

, , , , .

?

, .

0

All Articles