私は一日中プロファイルを保存することに頭を悩ませていましたが、それを達成できませんでした.
プロファイルの作成、削除はできますが、詳細を編集することはできません!
しばらく苦労した後、SQL Server プロファイラーのログを見て、確かに詳細を保存していることがわかりましたが、どういうわけか同じ sproc が以前の詳細でレコードを更新しています! デバッグを試みましたが、ページまたはマスター ページのページ読み込みイベントが発生しませんでした。
db トランザクションに問題がある可能性はありますか? しかし、私のコードにはトランザクション処理機能がないため、ロールバックなどで何かを行う必要があるかどうかは疑問です!
誰かがバグを見つけた場合に備えて、ここに私のコードがあります!
web.config
<profile defaultProvider="CustSqlProfileProvider" enabled="true">
<providers>
<add name="CustSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="connString" applicationName="/save_online"/>
</providers>
<properties>
<add name="FirstName" type="System.String"/>
<add name="LastName" type="System.String"/>
<add name="Email" type="System.String"/>
<group name="Address">
<add name="Street" type="System.String"/>
<add name="City" type="System.String"/>
<add name="PostalCode" type="System.String"/>
</group>
<group name="Contact">
<add name="Phone" type="System.String"/>
<add name="Mobile" type="System.String"/>
</group>
<add name="ShoppingCart" type="psb.website.BLL.Store.ShoppingCart" serializeAs="Binary" allowAnonymous="true"/>
</properties>
</profile>
コード
private void UpdateProfile()
{
ProfileCommon myprofile = this.Profile.GetProfile(HttpContext.Current.User.Identity.Name);
myprofile.FirstName = tbFirstName.Text.Trim();
myprofile.LastName = tbLastName.Text.Trim();
myprofile.Email = tbEmail.Text.Trim();
myprofile.Address.Street = tbStreetPhysical.Text.Trim();
myprofile.Address.City = tbCity.Text.Trim();
myprofile.Address.PostalCode = tbPostalCode.Text.Trim();
myprofile.Contact.Phone = tbPhone1.Text.Trim();
myprofile.Contact.Mobile = tbMobile.Text.Trim();
myprofile.Save();
}
SQL プロファイラー トレース内
exec dbo.aspnet_Profile_SetPropertiesは、ProfileCommon の save() が呼び出されたときに正しい値で実行され、ページの読み込みが完了した後、同じ st.procedure が以前の値で再度実行されます。2回目はなんていうの!? これはめんどくさい!!
SQL Server プロファイラーからのこのデータは役に立ちますか?
-- network protocol: LPC
set quoted_identifier on
set arithabort off
set numeric_roundabort off
set ansi_warnings on
set ansi_padding on
set ansi_nulls on
set concat_null_yields_null on
set cursor_close_on_commit off
set implicit_transactions off
set language us_english
set dateformat mdy
set datefirst 7
set transaction isolation level read committed
詳細: 管理者は他のユーザーのプロフィール情報を更新できますが、自分のプロフィールを更新することはできません。また、他の Web サイト ユーザーもプロファイル情報を更新できません。
不思議ですね!
誰か私を救ってください!