我試圖在代碼後面獲取配置文件屬性。但我沒有得到任何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