[英]how to add custom parameters to membership create user wizard?
我現在真的很困惑。 我已經閱讀了一些解決此問題的解決方案,但是每個解決方案都不盡相同。...有人說Web應用程序項目和網站項目需要不同的解決方案。
我有什么想法:
我有一個Web應用程序項目
我在該表中創建了一個表UserProfile
,其中存儲了其他列,例如圖像的鏈接。
我現在的問題是,當我在提交時調用RegisterUser_CreatedUser
時,找不到任何方法來獲取新創建用戶的Guid:
protected void RegisterUser_CreatedUser(object sender, EventArgs e)
{
FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false);
TextBox ImageUrl = RegisterUserWizardStep.ContentTemplateContainer.FindControl("ImageUrl") as TextBox;
UserProfile.SaveNewProfileInformation("place for new created user guid", ImageUrl.Text);
string continueUrl = RegisterUser.ContinueDestinationPageUrl;
if (!OpenAuth.IsLocalUrl(continueUrl))
{
continueUrl = "~/";
}
Response.Redirect(continueUrl);
}
如何獲得新創建用戶的向導? 我是否完全走上了解決這個問題的正確道路?
您需要使用UserName獲取創建的用戶
{
FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false);
//If user is created, get it by UserName
MembershipUser createdUser = Membership.GetUser(RegisterUser.UserName);
Guid userID = new Guid(createdUser.ProviderUserKey.ToString());
TextBox ImageUrl = RegisterUserWizardStep.ContentTemplateContainer.FindControl("ImageUrl") as TextBox;
//Use the userID from the above code
UserProfile.SaveNewProfileInformation(userID, ImageUrl.Text);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.