Tôi có một trang web có chứa điều khiển createuserwizard. Và khi tạo tài khoản, email xác minh cùng với URL xác minh sẽ được gửi đến địa chỉ email của người dùng.Hướng dẫn phải chứa 32 chữ số với 4 dấu gạch ngang
Tuy nhiên, khi tôi có một chạy thử, khi cách nhấp vào URL trong email, lỗi này xuất hiện:
Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Source Error:
Line 17: {
Line 18: //store the user id
*Line 19: Guid userId = new Guid(Request.QueryString["ID"]);*
Line 20:
Error appeared on LINE 19.
Một điều thú vị là, các URL xác minh trong tôi chạy thử trông lạ:
http://localhost:4635/WebSite2/Verify.aspx?ID=System.Security.Principal.GenericPrincipal
Thông thường, URL nên như thế này (mà là một toàn bộ rất nhiều nhân vật ở phần cuối của URL:
http://localhost:2180/LoginPage/EmailConfirmation.aspx?ID=204696d6-0255-41a7-bb0f-4d7851bf7200
Tôi đã thực sự nghĩ rằng, nó có một kết nối với sự kết thúc của URL với vấn đề của tôi về lỗi (Guid nên chứa 32 chữ số với 4 dấu gạch ngang) ..
Mã tạo URL như sau:
protected void CreateUserWizard1_SendingMail(object sender,MailMessageEventArgs e)
{
string domainName = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
string confirmationPage = "/Verify.aspx?ID=" + User.ToString();
string url = domainName + confirmationPage;
e.Message.Body = e.Message.Body.Replace("<%VerificationUrl%>", url);
}
Vui lòng cho tôi đề xuất và những gì tôi nên làm để giải quyết vấn đề này.
Xin cảm ơn trước.
UPDATE:
protected void CreateUserWizard1_SendingMail(object sender,MailMessageEventArgs e)
{
MembershipUser userInfo = Membership.GetUser(CreateUserWizard1.UserName);
Guid userInfoId = (Guid)userInfo.ProviderUserKey;
string domainName = Request.Url.GetLeftPart(UriPartial.Authority) + Request.ApplicationPath;
string confirmationPage = "/Verify.aspx?ID=" + userInfo.ToString();
string url = domainName + confirmationPage;
e.Message.Body = e.Message.Body.Replace("<%VerificationUrl%>", url);
}
Bây giờ URL của tôi liên kết cái nhìn như thế này:
http://localhost:4635/WebSite2/Verify.aspx?ID=username
Nhưng lỗi "Guid nên chứa 32 chữ số với 4 dấu gạch ngang (xxxxxxxx-xxxxxxxx-xxxx -xxxxxxxxxxxx "vẫn được giữ nguyên là
Làm thế nào để hiển thị cho chúng tôi mã tạo liên kết? Đó rõ ràng là vấn đề nằm ở đâu. – spender
đây là mã để tạo URL: bảo vệ void CreateUserWizard1_SendingMail (đối tượng người gửi, MailMessageEventArgs e) { // MembershipUser userInfo = Membership.GetUser (CreateUserWizard1.UserName); // Hướng dẫn sử dụngInfoId = (Hướng dẫn) userInfo.ProviderUserKey; string domainName = Request.Url.GetLeftPart (UriPartial.Authority) + Request.ApplicationPath; xác nhận chuỗiPage = "/Verify.aspx?ID=" + User.ToString(); string url = domainName + confirmationPage; e.Message.Body = e.Message.Body.Replace ("<% VerificationUrl%>", url); } – user1467175