i have a guid value that i store in my hidden variable. say for eg (303427ca-2a5c-df11-a391-005056b73dd7)
now how do i convert the value from this hidden field back to GUID value (because the method i would be calling expects a GUID value).
thank you.
Just use the overloaded constructor:
try
{
Guid guid = new Guid("{D843D80B-F77D-4655-8A3E-684CC35B26CB}");
}
catch (Exception ex) // There might be a more appropriate exception to catch
{
// Do something here in case the parsing fails.
}
You are making it pretty easy on an attacker by storing the Guid in a string. Trivial to find back in, say, the paging file. Store it in a Guid and kill two birds with one stone.
string strGuid;
strGuid = (your guid here);
Guid guid = new Guid(strGuid);
For more info, MSDN
Guid has a constructor for string Guids.
Guid guid = new Guid(myStringGuid);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With