Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.00/5 (1 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");

Membership.UpdateUser(user);



ActiviationNameLabel.Text = user.UserName;

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

if (user.IsApproved)
{

ActivationStatusLabel.Text = "Active";

}

else
{

ActivationStatusLabel.Text = "Pending";

}

}


//}


//catch
//{
//}



}
</pre>




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!
Posted
Updated 18-Apr-11 20:13pm
v3
Comments
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

A GUID looks like this
372FCE38-4324-11D0-8810-00A0C903B83C

Are you having this kind of value in Request.QueryString["ID"]?
If not then query proper string.
 
Share this answer
 
Comments
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900