Click here to Skip to main content
14,271,804 members
Rate this:
Please Sign up or sign in to vote.
See more:
It shows me the error that id should be 4 hyphen 32 bit. How can I solve this problem?
<pre> if (!Page.IsPostBack)
// Guid gd = new Guid(userID);

Guid userID;
userID = new Guid(Request.QueryString["ID"]);

MembershipUser user = Membership.GetUser(userID);

user.IsApproved = true;

Roles.AddUserToRole(user.ToString(), "Power Users");


ActiviationNameLabel.Text = user.UserName;

ActivationCreationDateLabel.Text = user.CreationDate.ToShortDateString();

if (user.IsApproved)

ActivationStatusLabel.Text = "Active";



ActivationStatusLabel.Text = "Pending";






error is
Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).

Source Error:

Line 28:
Line 29: Guid userID;
Line 30: userID = new Guid(Request.Params["ID"]);
Line 31:
Line 32: MembershipUser user = Membership.GetUser(userID);

Source File: c:\Documents and Settings\Pennar\Desktop\Workspace\activate.aspx.cs Line: 30

Stack Trace:

[FormatException: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).]
System.Guid..ctor(String g) +2486
activate.Page_Load(Object sender, EventArgs e) in c:\Documents and Settings\Pennar\Desktop\Workspace\activate.aspx.cs:30
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Thanks in advance!
Updated 18-Apr-11 20:13pm
Manfred Rudolf Bihy 18-Apr-11 9:44am
Edit: Added code tags, edited spelling and grammar.

What line does this error occur, please point that out in your question and also copy the complete error message incusive the stack trace. This will give us a little more to go on.
Another interesting item would be the exact value to the parameter ID to your webpage.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

A GUID looks like this

Are you having this kind of value in Request.QueryString["ID"]?
If not then query proper string.
Starlene 19-Apr-11 1:25am
how will i convert the userid to Guid ?
Debojyoti Majumder 19-Apr-11 1:59am
What value you are having in Request.QueryString["ID"]?
Starlene 19-Apr-11 2:02am
it stores the value of userid ?but it is int value like 1006

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100