Create GUIDa in ASP. NET

Source: Internet
Author: User
Basic knowledge
GUID indicates a globally unique identifier. As the name indicates, these numbers are statistically unique, meaning that there will not be two identical GUIDs in the world. Why?
A guid is a 128-bit number, usually expressed in a 32-bit hexadecimal string, like this: 3e4dab67-ac0b-47cc-b1cf-40f93324350f
The probability that two GUIDs are equal is 1/2128, which is almost 0.
Because of their uniqueness, GUID can be used in applications that require unique keywords, but in this case, keywords cannot be combined to generate a keyword.
For example, you want to track site visitors. If you do not ask a visitor some questions, it is impossible to generate table keywords containing their action information. Only when you have their identification information, such as phone numbers. Without such information, you can use a unique number, such as a counter, as a keyword. To make this ID unreproducible, you can use the GUID.
If a counter is used, a number may be copied. For example, if a counter is reset, but GUID is used, this is not possible.
Create a GUID in ASP. NET
In the ASP era, to generate a GUID, you must rely on an external COM component or SQL Server. Now, the. NET Framework provides the necessary classes for creating GUIDs, making it easy to generate GUIDs. The System namespace contains the GUID class, which contains the NewGUID () method. When called, a GUID object with a new value is returned. Now let's take a look at a simple example of generating a new GUID:
<Html>
<Body>
<% = System. GUID. NewGUID () %>
</Body>
</Html>
Click here for demonstration.
Refresh the demo page and you will find that a new GUID is displayed each time.
The following code is a "modified" version. Clicking "Create GUID" triggers the creation of a new GUID:
<Html>
<Script language = "vb" runat = "server">
'When you click the "Create GUID" button, the following precaution is called:
Sub displayNewGUID (Sender As Object, E As EventArgs)
'Set the label content to a new GUID value.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.