title: How can I access web.config Profile properties in ASP.NET 4.5?
body: <p>I look through the ASP.NET 4.0 online cource, just one of the first lessons.</p>
  
  <p>I have Visual Studio 2012 for Web installed, and it has ASP.NET 4.5 on board.</p>
  
  <p>In order to access some web.config properties, guy in the course writes following line:</p>
  
  <pre><code>Profile.Preferences.MyParameter = "MyValue";
  </code></pre>
  
  <p>but when I type the same thing, it gives me an error: <i><code>Profile element doesn't exist in the current context</code></i>. And when I'm trying to access <code>System.Web.Profile.Preferences</code>, it says that <i><code>Type or namespace "Preferences" is missing in System.Web.Profile</code></i>.</p>
  
  <p>Can anyone please tell what's happening? Is ASP.NET 4.5 the reason of this behavior, and if yes - how can I access the same web.config properties is ASP.NET 4.5?</p>
  
  <p>My web.config looks like that:</p>
  
  <pre><code>&lt;configuration&gt;
    &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5" /&gt;
      &lt;profile&gt;
        &lt;properties&gt;
          &lt;group name="Preferences"&gt;
            &lt;add name="MyParameter"/&gt;
          &lt;/group&gt;
        &lt;/properties&gt;
      &lt;/profile&gt;
    &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>UPDATE:
  I've tried to implement the second solution from Joel Spolsky's answer: <a href="https://stackoverflow.com/questions/426609/how-to-assign-profile-values">How to assign Profile values?</a></p>
  
  <p>But the code doesn't work for me. The following method crahes:</p>
  
  <pre><code>static public AccountProfile CurrentUser
      {
          get { return (AccountProfile)
                       (ProfileBase.Create(Membership.GetUser().UserName)); }
      }
  </code></pre>
  
  <p>It happens because Membership.GetUser() returns null. What Can I do with that?</p>