Guid should contain 32 digits with 4 dashes

asp.net, c#

Solution

You've got a line that says:

Guid userInfoId = (Guid)userInfo.ProviderUserKey;

Surely this is what you should provide in the URL?

string confirmationPage = "/Verify.aspx?ID=" + userInfoId.ToString();

Problem

I had a website which contains a createuserwizard control. And upon creating an account, verification email along with its verify URL would be send to the user's email address. However, when i have a test-run, upon clicking the URL in the email, this error appear: ``` 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. ``` Another funny thing is, the verification URL in my test-run look weird : ``` http://localhost:4635/WebSite2/Verify.aspx?ID=System.Security.Principal.GenericPrincipal ``` Normally, the URL should like this(which is a whole lot of characters at the end of the URL: ``` http://localhost:2180/LoginPage/EmailConfirmation.aspx?ID=204696d6-0255-41a7-bb0f-4d7851bf7200 ``` I was actually thinking that, it there a connection with the end of the URL with my problem of the error (Guid should contain 32 digits with 4 dashes).. The code that generates the URL is as follows: ``` 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); } ``` Please give me suggestions and what I should do to solve this problems. Thanks in advance. 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); } ``` Now my URL Link look like this : ``` http://localhost:4635/WebSite2/Verify.aspx?ID=username ``` But the error "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" still remained

Original source