Can't access custom profile properties from web.config?

I have the following two profile properties in the web.config file between System.Web tags:

<anonymousIdentification enabled="true"/>
<profile>
  <properties>
    <add name="CustomerName" allowAnonymous="true"/>
    <add name="CustomerID" allowAnonymous="true"/>
  </properties>
</profile>

When I try to get the name Profile.CustomerName or Profile.CustomerID from the aspx.cs file, it does not appear. I thought that when creating my own profile property, it automatically updates aspnetdb with the new properties. The profile also does not appear in intellisense.

+3
source share
2 answers

, -. -, -, ProfileCommon. : http://webproject.scottgu.com/CSharp/Migration2/Migration2.aspx ( 2)

, - . :

Object customerName = HttpContext.Current.Profile.GetPropertyValue("CustomerName") 

intellisense , , , , .

+2

web.config : ProfilePropertyWeb.config

: -

Code Behind Profile Properties

. : -

Output

0

Source: https://habr.com/ru/post/1720529/


All Articles