我试图在代码后面获取配置文件属性。但我没有得到任何intellisence像Profile.Homephone
或Profile.CellPhone
。当我尝试:未在代码后面获取配置文件属性
Dim memberprofile As ProfileBase = HttpContext.Current.Profile
Dim homePhone As String = memberprofile.GetPropertyValue("HomePhone").ToString()
我得到。无法在Null值错误上调用此方法或属性。我在配置文件表中有当前用户的数据。 我得到以下结果在即时窗口
?HttpContext.Current.Profile.UserName.ToString "sub2" ?Profile.DefaultProfile.Properties.Count 2 ? HttpContext.Current.Profile("HomePhone") "" {String} String: ""
我不能够在页面加载事件运行的属性值。 这是我的web.config文件设置:
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider" connectionStringName="Primary" applicationName="MyFmNow.com"
type="System.Web.Profile.SqlProfileProvider" />
</providers>
<properties>
<add name="HomePhone" type="String" />
<add name="CellPhone" type="String"/>
</properties>
</profile>
This [weblog](http://weblogs.asp.net/anasghanem/archive/2008/04/12/the-differences-in-profile-between-web-application-projects-wap-and-website。 aspx)提供了有关此问题的一些有用信息。我面临着完全相同的问题,但链接的网站帮助我获得了不同。但我仍然在试图找出原因。 – 2011-04-09 18:32:18